## 4 The Proposed Community-Based Event Delivery Protocol
### Routing Strategies in Pub/Sub Systems for DTN  
In our network model, mobile subscribers are capable of continuously moving in different grids of the network. According to the RWP model, each subscriber is aware of its next destination location. Besides, mobile subscribers can easily obtain their locations from an attached extra device, for example a GPS. Thus, all the girds that a subscriber crosses can be easily acquired using the two aforementioned variables. The implementation of the event delivery strategy is composed of two steps. First, we discuss the process of determining whether a sensor in a community can communicate directly with a mobile subscriber node or not based on the current moving path of the subscriber nodes acquired by using mobility prediction. Then we present the detail event delivery strategy. Without loss of generality, we  
Figure 1: An example to illustrate communities of the network. consider the mobile subscriber node \(i\) and the community \(N\). The process of finding sensor nodes which could communicate directly with subscriber \(i\) in community \(N\) is conducted into four phases:  
(a) Initially, if the subscriber \(i\), while moving, comes within one grid, it will broadcast Hello messages to all its neighboring sensor nodes. The neighboring sensor nodes send back their information, including community numbers, grid numbers and their ID numbers to subscriber \(i\) thereafter. (b) Then, once subscriber node \(i\) finds out that it connects to community \(N\) for the first time, it sends out PATH messages including its current mobility path to its neighboring sensor nodes which belong to community \(N\). After that, these PATH messages are broadcasted among nodes in community \(N\). (c) When subscriber \(i\) changes its moving path after connecting to community \(N\), its current moving path should also be reported using the method mentioned in phase b. (d) After receiving the PATH messages, each sensor node in community \(N\) would compare its location with each grid that the node \(i\) passes, to learn whether it could communicate directly with node \(i\) or not. Let set \(Z\) denote sensors that could communicate directly with subscriber \(i\) in community \(N\). After determining the set \(Z\) of community \(N\), a routing graph is established based upon sensor nodes in set \(Z\). Firstly, each senor node in set \(Z\) broadcasts its node ID message to all its adjacent sensor nodes except the nodes in set \(Z\). For making an event delivery path towards the nodes in set \(Z\), the sensor node which receives the node ID message will regard the message sender as its downstream relay node at first, and then it will repeat the process of nodes in set \(Z\) and broadcast its node ID message to all its neighboring sensor nodes. Other sensor nodes will repeat the above mentioned process until all the nodes in community N are included in the routing graph. Finally, a routing graph is established. An example of the constructed routing graph is illustrated in Figure 2, where we assume the set \(Z\) of community 2 in our network model contains sensor nodes with ID numbers of 3 and 5. The event forwarding process is described as follows. Concretely, a sensor node forwards events of its own and those from the upstream nodes to its downstream. For sensor nodes that without upstream nodes, they just send their own events to the downstream. The sensors in the downstream will repeat this process until the events arrive at sensor nodes in set \(Z\). Finally, the events will be delivered to subscriber \(i\) once the node in set \(Z\) communicates directly with subscriber \(i\). Figure 2: The routing graph of community 2. Since a sensor node may have multi-relay-sensors in its downstream, events in the source sensor node are evenly forwarded to its next relay sensors then, with the aim of balancing energy depletion among the relay sensor nodes. An example can be seen from Figure 3, where the event forwarding process from node 7 to node 3 in Figure 2 is presented.