fig1 is a block diagram of one embodiment of a system and method for sharing information between protocol layers . a protocol stack 110 in a device includes an upper layer 120 and a lower layer 130 , which pass packets through a data interface : packets received from another device are passed up the stack through data interface 140 , while packets to be transmitted to another device are passed down the stack through data interface 150 . an information exchange service ( ies ) 160 communicates with upper layer 120 through interface 170 , and with lower layer 130 through interface 180 . ies 160 uses interfaces 170 and 180 to share control information between layers 120 and 130 . upper layer 120 uses control information originating from lower layer 130 and passed through interface 170 to adapt its behavior . lower layer 130 uses control information originating from upper layer 120 and passed through interface 180 to adapt its behavior . the control interfaces 170 and 180 are distinct from the data or packet interfaces 140 and 150 . the term “ control information ” is used to distinguish information passed through interfaces 170 and 180 from data or packets passed through interfaces 140 and 150 . examples of control information include information describing resources on the local device , application - layer information , and information about neighboring devices . however , many other types of control information are contemplated and intended to be within the scope of this disclosure . in some embodiments , these items of control information are attributes of particular layers . the example protocol stack 110 of fig1 includes only two layers , adjacent to each other . however , the embodiments described herein apply to inter - layer , or cross - layer , communication in stacks with more than two layers . the embodiments also apply to communication between non - adjacent layers , for example between a media access control ( mac ) layer ( also known as layer - 2 ) and a transport layer ( also known as layer - 4 ). in the example of fig1 , the communication between lower layer 130 and upper layer 120 through ies 160 is symmetric . that is , lower layer 130 receives information originating from upper layer 120 , and vice - versa . furthermore , the embodiments described herein may also be used asymmetrically . that is , there is no requirement that lower layer 130 receives information originating from upper layer 120 , even if upper layer 120 receives information originating from lower layer 130 . fig2 is a block diagram of one embodiment of the information exchange service ( ies ) 160 from fig1 . in this embodiment , the functionality of ies 160 is decomposed into an attribute manager 210 and an event manager 220 . attribute manager 210 implements sharing of attributes 230 between protocols layer through a putattribute interface 240 and a getattribute interface 250 . one protocol layer , acting as an attribute publisher 260 , uses putattribute interface 240 to store a particular attribute - value pair in ies 160 , for sharing with other layers . on registration , ies 160 writes the attribute - value pair 230 to ies storage 265 . another protocol layer , acting as an attribute subscriber 270 , uses getattribute interface 250 to retrieve a particular attribute - value pair 230 from ies storage 265 . information identifying publishers and subscribers may optionally be stored by ies 160 in a publisher list 275 and a subscriber list 280 . event manager 220 notifies protocol layers about changes to attributes 230 . a subscriber 270 registers for attribute change notification through notification interface 285 . in some embodiments , the notification interface 285 allows subscriber 270 to specify a rule 290 , expressed as a condition of an attribute 230 ( e . g ., “ energylevel & lt ; 5 ”). rules 290 are stored by ies 160 , and when the condition is met , event manager 220 invokes the registered callback ( 295 ) to notify subscriber 270 . in some embodiments , rules 290 are processed by rule execution logic 297 . these features in ies 160 provide both stackability and adaptability . access to attributes 230 is transparent to publishers and subscribers ( i . e ., publishers are unaware of subscribers and vice - versa ). attributes are extensible : new attributes 230 can be added without a change to the interfaces or to the underlying structure . for example , a new routing protocol can be substituted into protocol stack 110 , and that new routing protocol can publish a new attribute 230 that is not presently stored in ies 160 . having introduced both attribute manager 210 and event manager 220 , each will now be described in further detail . in some embodiments , each attribute 230 managed by attribute manager 210 has a unique identifier known to all the layers , and the attribute identifier maps to a unique declarative description of the attribute ( e . g ., an xml declaration of the attribute ). in such embodiments , a protocol layer can obtain an attribute &# 39 ; s identifier from the attribute &# 39 ; s declaration by contacting an attribute name server ( analogous to a dns lookup for a tcp address ). in some embodiments , the getattribute interface 250 provided by attribute manager 210 is synchronous , i . e ., the “ get ” semantic copies the value associated with the attribute ( if available ), and returns the number of bytes corresponding to the data value ( zero indicating that the data is currently unavailable ). in some embodiments , getattribute interface 250 is asynchronous , i . e ., the “ get ” semantic with a callback . in some asynchronous embodiments , the “ get ” semantic includes periodicity , so that the “ get ” callback is called periodically with updates of the attribute &# 39 ; s value . in such embodiments , the putattribute interface 240 uses a “ put ” semantic with an expiration parameter , which specifies a time at which the attribute &# 39 ; s value is no longer valid . further details of asynchronous embodiments will be described later in connection with fig3 . as described above , some embodiments of event manager 220 provide rule - based notification . one such embodiment of event manager 220 is implemented by registering itself as a subscriber 270 of attribute manager 210 for the attribute in the specified rule 290 . when notified by attribute manager 210 of a change to the attribute value 230 ( e . g ., through getattribute interface 250 ), event manager 220 checks the condition specified by rule 290 , and if the condition is met , notifies the subscribing protocol layer by invoking the registered callback 295 . some embodiments of attribute manager 210 use a fully - associative cache to store attributes 230 . although the cache may use various replacement policies , a least - recently used cache policy is particularly advantageous in protocol stacks where different layers cooperate to achieve some common goal ( e . g ., energy optimization ) and therefore may query a common attribute from ies ( e . g ., remaining battery level ). in embodiments in which ies storage 265 is limited or finite , ies 160 may decide to evict , or retire , attributes 230 from storage to make room for more . examples of an eviction policy include least recently used ( lru ) and using a priority associated with each 230 . since in some cases this eviction may occur before any subscriber 270 requests it , some embodiments of ies 160 allow the publisher 260 to tag the data with a sticky bit to override the eviction policy . alternatively , attribute manager 210 may asynchronously “ pull ” the data from a publisher upon a request from a subscriber . a cache implemented by one example attribute manager 210 uses fixed length attribute - value pairs , stored in an array . each attribute is directly mapped to an entry in a hash table ( not shown ), where the hash table maps the attribute to an index in the array . thus , if the attribute is present in the hash table , then its value can be directly accessed from the array . if the attribute is not present in the hash table , then the array is searched . by keeping the set associative , the search space is reduced to the associativity factor . as an example , for a hash table of 8 entries , and a 16 - way set - associative data bank of 256 entries , each hash table entry will be 24 bits ( 16 - bit attribute address and 8 - bit array index ). for a hit in the hash table ( a “ cache hit ”), an attribute is accessible in 2 comparisons ( one to hash table , and another to the array ). for a miss in the hash table ( a “ cache miss ”), an attribute is accessible in at most 17 comparisons ( one to hash table , and at most 16 to the array ). fig3 is a message flow diagram illustrating one embodiment of an asynchronous get / put interface implemented by ies 160 . the initial getattribute request 310 ( issued by subscriber 270 ) initially returns with failure 320 because the requested attribute 230 ( in fig2 ) is not available in ies storage 265 ( in fig2 ). such a failure 320 may occur when no publisher 260 has put / written the attribute 230 , or when the attribute 230 was evicted ( possibly as a result of expiration ) from ies storage 265 . on failure 320 , ies 160 determines if any publisher 260 has registered for the requested attribute 230 , and it sends a data request message 330 to the registered publisher 260 . at a later time , publisher 260 puts ( 340 ) the attribute 230 . in response to put 340 , ies 160 notifies the registered subscriber 270 using a data available message 350 , which includes a pointer to the attribute data . using the pointer in data available message 350 , subscriber 270 accesses the attribute 230 in ies storage 265 . timing may be such that before the subscriber 270 handles data available message 350 , attribute 230 been evicted from ies 160 , which renders the data available message 350 void . to prevent attribute 230 from getting evicted before data available message 350 is processed by subscriber 270 , ies 160 keeps an eviction time window : a minimum time before which the attribute is guaranteed to be available from ies 160 . a subscriber 270 is expected to handle data available message 350 within the time window , or else the subscriber 270 must issue a new getattribute request . fig4 is a message flow diagram illustrating another embodiment of an asynchronous get / put interface implemented by ies 160 . subscriber 270 issues a getattribute request 410 using a periodic parameter . in some embodiments , getattribute request 410 is non - blocking . in response , ies 160 periodically determines whether if the requested attribute 230 has expired , or is unavailable in ies storage 265 . if either condition is true , ies 160 signals publisher 260 with a data ready message 420 . publisher 260 responds by updating the value of attribute 230 with a putattribute 430 . ies 160 responds by sending a data available message 440 to subscriber 270 . in this example scenario , the requested attribute 230 expires twice , resulting in two data ready messages ( 420 and 450 ), which in turn results in two putattributes ( 430 and 460 ) and two data available messages ( 440 and 470 ). ies 160 may use multiple timers to maintain periodicity ; because of the asynchronous nature , the periodicity cannot be guaranteed to be accurate , but may instead depend on how fast publishers 260 are able to handle the data ready messages 420 . the protocol stack architecture described , in which information is shared across layers in a device , has wide applicability to many different types of protocol stacks . additional enhancements are now described to share information across nodes . these enhancements have general applicability , but are particularly useful in a wireless sensor network . in addition to the vagaries of the wireless network itself , nodes are often resource - constrained , which can pose additional challenges for the protocol stack . nodes may join or leave the network to save their individual battery power , or environment conditions may vary which result in dynamic changes to network topology . applications running on sensor networks are often to be network - centric , which leads to cooperation among nodes in order to meet application requirements . thus the modules which implement the different layers of the protocol stack at a given sensor node may need to adapt to changes in node conditions at remote nodes . the information dissemination service described herein supports this by allowing one node to subscribe to remote ieses , and / or to aggregate and share useful information from multiple nodes . as one example , a sensor fusion application can monitor the health of its neighbor nodes periodically for role assignment decisions . as another example , an energy conscious routing module uses the same information in making routing decisions . thus , queries for such information may emanate not only from the application level but also from different layers of the sensor protocol stack to remote nodes . there may be considerable overlap in different queries . consider two nodes issuing the same query , “ which of my 2 - hop neighbors have 80 % battery level ?”. if the two nodes are topologically close to each other , then considerable overlap in the results are likely as well . the results may be exactly the same if the two nodes share the same neighborhood . however , if the queries are processed independently in the network it would lead to significant overhead due to the duplication . the information dissemination service ( ids ) described herein provides a unified framework for information sharing across nodes . ids supports a stream of queries over remote ies data with reduced communication overhead . two sources of redundant communication in supporting ies across nodes are overlap in the scope of queries executed at different nodes , and rate of queries as compared to rate of change in remote data . ids uses various techniques to reduce such communication redundancy and to provide ids support in a scalable and adaptable manner . the high - level query interface provided by ids is expressive and allows detection of possible overlap among different queries . a typical query may appear as follows : “ select attributes fx ; y ; zg from all nodes within the scope s satisfying the conditions fp ; q ; rg , and deliver the results with a periodicity of t .” queries overlap if and only if the scope of the participating nodes as well as the collected results overlap . detecting such an overlap helps control flooding of a query , as well as sharing of the results . overlaps can be full or partial , either in their scope , attributes of the query , and / or the results . once a query overlap is detected , the results can be shared to save on the network communication for the results . ids shares results among queries , where one query subsumes another , both in scope and attributes . ids also determines if there is a partial overlap among queries , and then executes the partially overlapping queries in the non - overlapping scopes , while reducing or avoiding duplication of results . ids supports both region - based and global queries . when a protocol module initiates a region - based query , first a region is created by informing all the neighboring nodes that may lie within the scope . to limit flooding of beacon packets , a region is scoped either in terms of number of hops or physical distance from the initiator node . a beacon packet consists of a region identifier , scope , and a set of predicates . a node receiving a beacon checks if it lies within the scope of the region , and if it does not , it ignores the packet . otherwise , the node becomes a member of the region and it broadcasts the beacon packet . thus the beacon packet is propagated as a wave originating from the initiator node and the wave dies beyond the query scope . if a node satisfies the beacon &# 39 ; s predicates , it also acts as a producer node , i . e . it will need to send the query response to the consumer node . in the first embodiment described , the response is sent back periodically . embodiments described later optimize the response to decrease communication overhead . an obvious option to disseminate data from the producer nodes to their consumers is to create data diffusion trees , with the consumer nodes at the tree roots . since there will be as many trees as the queries , supporting data sharing across different trees becomes important as the number of trees grows . however , efficient sharing across different diffusion trees can be difficult , typical solutions incur the overhead of tree maintenance and also disseminating tree attributes continuously , to allow sharing of the tree by other nodes . because of such overheads , using diffusion trees for control data dissemination becomes inefficient as the number of trees grows . another option is to flood the produced data to the whole region . as the number of consumer nodes increase within a region , the overhead of flooding per consumer node decreases , especially when the consumer nodes are subscribed to same control data . since control data packets are smaller , and they can be piggybacked with each other to be sent as a single packet , even consumers with differing attribute requests help to amortize the flooding cost . ids uses both of the above techniques depending on the network conditions . to optimize the communication overhead , flooding is scoped within a query region only . also , to avoid the broadcast storm problem , ids controls the rebroadcast probability . having discussed regional - based queries , global queries will now be described . in handling global queries , ids utilizes a support service for location awareness , and uses geographically - scoped queries . in a location - aware sensor network , nearness can be easily captured using physical distance . however , since sensor network links have been found to be asymmetric in nature , physical distance may not be able to capture reliability and hop - count between nodes . still , location - based querying provides an easy way to express scope , where finding spatial overlap among queries becomes straightforward . relative coordinates are used for location identification , avoiding the need for extra hardware such as gps at a node . using location - based scoping for queries , the spatial overlap can be easily detected by finding the common areas from the scope . to share the results among overlapping scopes , ids divides the topology into smaller clusters with a cluster head that knows the membership of the nodes within a cluster . query - aware hierarchical clustering allows information sharing at the cluster level , thus avoiding the overhead of flooding inside clusters ( if the cluster head already has the query results ). some embodiments of use ids dynamically construction of hierarchical clusters to further optimize queries , perform result aggregation , and result sharing . some embodiments add result filters that are cognizant of “ partial overlap ” at cluster heads and / or at strategic nodes in the network . some embodiments of ids support dynamic role migration , where the role played by a cluster head can migrate to other nodes . cluster heads are the nodes that act as the root of a local aggregation tree . these nodes are responsible for deciding if a query needs to be flooded within a cluster . some embodiments of ids perform cluster formation and cluster head selection using simple location - aware clustering algorithms such as leach . the leach algorithm gives a two - level cluster hierarchy , with data sources at first level , and cluster - heads at the second level . some embodiments of ids represent a location - based scope of a query as a tuple & lt ; x ; y & gt ;, such that any node in a square region of length x and width y , with respect to the node &# 39 ; s current location , becomes the area of interest . in these embodiments , cluster heads , having a cluster - level view of all existing query trees and membership information , participate actively in query optimizations . for example , consider an aggregation tree rooted at a sink node , spanning the entire network . now , if another sink wishes to build a query aggregation tree , and if the new tree physically overlaps with the earlier one , then within the overlap region , only cluster - heads need to report the results back to the new sink . the non - overlapping regions will be handled using techniques known to a person of ordinary skill in the art . some embodiments of ids build on the dfuse role assignment algorithm to load balance the cluster head role . ( this algorithm is described in “ dfuse : a framework for distributed data fusion ”, by r . kumar , m . wolenetz , b . aganvalla , j . shin , p . hutto , a . paul , and u . ramachandran , in sensys &# 39 ; 03 : proceedings of the 1st international conference on embedded networked sensor systems , which is incorporated by reference .). during the maintenance phase of the dfuse algorithm , every node hosting a particular role is responsible for either continuing to play that role or transferring the role to one of its neighbors . the decision for role transfer is taken solely by the current role player based upon local information . a role player , i . e ., a cluster head in ids , periodically informs its neighbors about its role and its health ( an indicator of how good the node is in hosting that role . upon receiving such a message , a neighboring node computes its own health for hosting that role . if the receiving node determines that it can play the role better than the sender , then it informs the sender its intent for hosting that role . if the sender receives one or more intention requests from its neighbors , the role is transferred to the neighbor with the best health . some embodiments of ids support on - demand clustering by partitioning the network into a static grid , where inter - node distance corresponds to one - hop transmission range . however , because of the inherent dynamic nature of sensor networks , static clustering may not be suitable . also , quite often only a part of the deployed network may be involved in maintenance activities warranted by ids ( or even application level queries ). creating and maintaining clusters over the entire network may lead to unnecessary control overhead . on - demand clustering reduces such control overhead . a person of ordinary skill in the art should recognize that the software components illustrated in fig1 - 2 are abstractions chosen to illustrate how some embodiments of a system and method for sharing information between protocol layers partition functionality among components . such a person should also recognize that other divisions of functionality are also possible , and these other possibilities are intended to be within the scope of this disclosure . furthermore , to the extent that software components in fig1 - 2 are described in terms of specific data structures such as arrays , lists , flags , pointers , collections , etc ., a person of ordinary skill in the art should appreciate that other data structures providing similar functionality can be used instead . as just one example , a particular implementation might use a linked list instead of an array . a person of ordinary skill in the art should understand that software components referred to herein include executable code that is packaged , for example , as a standalone executable file , a library , a shared library , a loadable module , a driver , or an assembly , as well as interpreted code that is packaged , for example , as a class . in general , the components used by the systems and methods of sharing information between protocol layers are described herein in terms of code and data , rather than with reference to a particular hardware device executing that code . furthermore , one of ordinary skill in the art will understand that the systems and methods can be implemented in any programming language , and executed on any hardware platform . any process descriptions or blocks in flowcharts should be understood as representing modules , segments , or portions of code which include one or more executable instructions for implementing specific logical functions or steps in the process . as would be understood by those of ordinary skill in the art of the software development , alternate implementations are also included within the scope of the disclosure . in these alternate implementations , functions may be executed out of order from that shown or discussed , including substantially concurrently or in reverse order , depending on the functionality involved . fig5 is a hardware block diagram of a device 500 in accordance with a system and method for sharing information between protocol layers . device 500 contains a number of components that are familiar to a person of ordinary skill in the art , including a processor 510 , at least one network interface 520 , memory 530 , and non - volatile storage 540 . a person of ordinary skill in the art should understand that the networks interfaces may be of different types , support different medias and speeds , etc . examples of non - volatile storage include , for example , a hard disk , flash ram , flash rom , eeprom , etc . these components are coupled via bus 550 . memory 530 contains instructions which , when executed by the processor 1110 , implement the methods and systems disclosed herein . memory 530 contains protocol stack 110 and information exchange service ( ies ) 160 from fig1 . omitted from fig5 are a number of conventional components that are not necessary to explain the operation of device 500 . the systems and methods disclosed herein can be implemented in software , hardware , or a combination thereof . in some embodiments , the system and / or method is implemented in software that is stored in a memory and that is executed by a suitable microprocessor , network processor , or microcontroller situated in a computing device . in other embodiments , the system and / or method is implemented in hardware , including , but not limited to , a programmable logic device ( pld ), programmable gate array ( pga ), field programmable gate array ( fpga ) or an application - specific integrated circuit ( asic ). the systems and methods disclosed herein can be embodied in any computer - readable medium for use by or in connection with an instruction execution system , apparatus , or device . such instruction execution systems include any computer - based system , processor - containing system , or other system that can fetch and execute the instructions from the instruction execution system . in the context of this disclosure , a “ computer - readable medium ” can be any means that can contain , store , communicate , propagate , or transport the program for use by , or in connection with , the instruction execution system . the computer readable medium can be , for example but not limited to , a system or propagation medium that is based on electronic , magnetic , optical , electromagnetic , infrared , or semiconductor technology . specific examples of a computer - readable medium using electronic technology would include ( but are not limited to ) the following : an electrical connection ( electronic ) having one or more wires ; a random access memory ( ram ); a read - only memory ( rom ); an erasable programmable read - only memory ( eprom or flash memory ). a specific example using magnetic technology includes ( but is not limited to ) a portable computer diskette . specific examples using optical technology include ( but are not limited to ) an optical fiber and a portable compact disk read - only memory ( cd - rom ). the foregoing description has been presented for purposes of illustration and description . it is not intended to be exhaustive or to limit the disclosure to the precise forms disclosed . obvious modifications or variations are possible in light of the above teachings . the implementations discussed , however , were chosen and described to illustrate the principles of the disclosure and its practical application to thereby enable one of ordinary skill in the art to utilize the disclosure in various implementations and with various modifications as are suited to the particular use contemplated . all such modifications and variation are within the scope of the disclosure as determined by the appended claims when interpreted in accordance with the breadth to which they are fairly and legally entitled .