# Querying on Federated Sensor Networks
## 3 L-FSN Protocol
### Inter-Island Querying  
For inter-island communication, upmost-tier gateways form a backbone tree. Gateways perform both as a router and as a protocol translator. Gateways know where to direct a given packet using their routing tables and convert packets according to the protocol in which data is navigating with respect to the data formats and data rate.  
While BGP uses longest-prefix matching to inform subnets on the internet, L-FSN uses the area boundary information. Using the area boundary information, query packets are forwarded to the  
\begin{table}
\begin{tabular}{l} \hline \hline Identifier \\ Island identifier \\ Latitude \\ Longitude \\ Latitude of the North-East boundary \\ Latitude of the South-West boundary \\ Longitude of the South-West boundary \\ Metric \\ Next neighbor \\ Weight Status \\ \hline \hline \end{tabular}
\end{table}
Table 1: Fields of a routing table.  
corresponding EG(s) covering the geographical area of destination. Each IG calculates its area boundary according to the geographical coordinates of its underlying WSN nodes. IGs forward their boundary information to their assigned EG. An EG's boundary is the total boundary of its underlying IGs.  
By L-FSN, a query packet includes the data information along with the source and destination information as follows. The source information includes the source island identifier (id) and the source node id. The destination information includes the geographical coordinates of the destination node.  
Appendices B and C demonstrate the message processing algorithms. Appendix B explains the new message processing algorithm at a gateway. Gateway receive beacon, query and event messages. Sensor nodes join to gateways by sending beacon messages. Gateways send beacon messages periodically to other gateways to inform their existence. When a gateway receives a beacon message from a gateway, it updates its gateway routing table. Other than beacon messages, gateways receive query and event messages. By L-FSN, an island node can send query and event messages to either several islands or a specific island through gateways. Each time a gateway receives a query or an event message, it updates its records for further message propagation. A gateway can propagate a query into the entire FSN if a broadcast address is assigned for the query destination. Instead of a broadcast address, queries can be directed to specific islands by assigning NE and SW points of the destination area. If both NE and SW points are assigned to be same coordinates, query is routed to a destination point instead of a destination area. According to the destination address, gateways determine the next unit and forward query packets to the next unit on the query propagation path. Similarly, if a gateway receives an event message, it forwards event message to the next unit on the query propagation path. Appendix C explains the new message processing algorithm at a sensor node. A sensor node receives beacon messages from gateways. A sensor node records received query and event message information. Sensor nodes initiate query messages and receives corresponding event data. Moreover, sensor nodes replies to a query message if they have relevant data.  
Query and event data message flows on an FSN are demonstrated in Figure 2. By L-FSN, queries are sent to a destination as described below.