## 4 Service Provisioning Over NEURON  
The creation of an overlay topology is beneficial for decentralized and autonomic service provisioning in WSNs. Multiple challenges, though, have been identified due to the dynamic network characteristics in such networks. P2p protocols may efficiently manage the sensors' interconnections (as nodes continuously join or leave from the overlay network) or control the autonomic delegation of tasks among participating nodes [10,42]. Addressing scalability and complexity challenges, though, is still a research issue [49]. NEURON exhibits the necessary functionality to upper layer protocols in order to establish an overlay network while aims to address complexity and scalability issues. It also provides routing information to topology formulation mechanisms in order to improve their efficiency. Several topology formulation algorithms have been proposed in the literature [41,46,47]. The T-MAN algorithm was selected for investigating the advantages that NEURON may offer to the overlay topology formulation mechanisms due to the faster convergence capabilities of T-MAN compared to other alternatives for the creation of an overlay topology [50]. T-MAN allows communications with any node in the overlay network contrary to other gossiping protocols that permit communications with only the one-hop-away neighbours (refer to Section 3.1). The latter approach increases routing overhead as one node has to identify a proper route prior to attempt to communicate with another node in the overlay network. In T-MAN, each node aims to identify its successor in the overlay topology based on the knowledge that acquires through the exchange of views with its neighbours. Scoring functions are applied for the selection of the successor of each node and the results are stored in a buffer. The scoring function affects the formation of the overlay network topology. In our case, a ring topology is formulated since Chord [42] was selected as a p2p protocol for the provision of storage and retrieval functionality over the created overlay network. Chord pre-assumes that nodes are ordered in a ring and are aware of their successor and predecessor in the overlay ring topology. However, any other topology may be also created based on the selected p2p protocol. T-MAN applies a gossiping technique [50] in order to indentify the relative position in the overlay (Table 2). Each node maintains a view with the nodes that are--up to a specific time--known and scored. Each node periodically communicates with the \"closest\" node and exchange views with it (Figure 6a,b). After this mutual exchange, nodes re-evaluate their views (Figure 6c,d). This iterative procedure leads to extremely fast convergence, _i.e._, the state in which each node knows its successor. Any further exchange of messages between the nodes does not improve the accuracy of their views (Figure 6e). The T-MAN algorithm is adapted in order to exploit information available through the NEURON mechanisms and thus minimize the messages that are necessary for convergence of the protocol in a WSN. Two improvements have been integrated to the T-MAN algorithm. Firstly, each node, before sending its buffer to a requestor, updates the buffer with nodes that score better than the existing ones by consulting its routing cache. Secondly, multiple messages are sent to any node in the buffer instead of sending one message to the first node of the buffer (i.e. the node that scores better). This facilitates the fast dissemination of information regarding the network topology which is critical in dynamic networks. These two adaptations reduce the total amount of messages required for overlay topology formulation, as shown in Figure 7.