# Querying on Federated Sensor Networks
## 1 Introduction  
Wide usage of Wireless Sensor Networks (WSNs) with various application purposes necessitates the federation of WSNs located at geographically distant locations. For example, in a campus environment, each building can be monitored by a WSN of several gas detectors, and a mechanic may send a gas leak query into the building complex in order to receive the geographical location of the gas leak area as a response [1]. In the same campus, each parking lot can be monitored by a WSN [2] and parking lots can be federated in order to allow distance-sensitive queries such as: \"Where is the nearest available parking space\". A single campus authority may demand to federate all WSNs in a campus environment, whether they are deployed on a building or a parking lot while still providing autonomous management of each WSN. We call a network of geographically distant WSNs a Federated Sensor Network (FSN), and call each WSN in an FSN an island. Within an FSN, a querying unit needs to be able to gather data from nearby or any island. While providing communication among islands, an FSN management needs to handle queries by running island-specific querying protocols at each island, so that each island can be operated as an autonomous system and connected to FSN with a degree of privacy. For improving scalability, including distance-sensitivity and increasing regional autonomy, a layered FSN management is beneficial for the federation of islands. For the layered management of an FSN, we develop the Layered Federated Sensor Network (L-FSN) Protocol for the federation of islands, inspired by the Border Gateway Protocol (BGP), which was developed for the federationof autonomous systems on the internet. On the internet, connection among autonomous systems is established by BGP in which a path vector algorithm is used for route selection according to the reachability of autonomous systems. BGP ensures that data is sent to the destination without communication loops with the best possible latency and provides an additional path if a path failure occurs. Due to these benefits, BGP principles correspond to the requirements of the layered FSN management. Applicability of BGP on FSN has several challenges. We will refer to some of these challenges, and clarify the corresponding adaptations on FSN by L-FSN protocol. BGP protocol uses local route preferences (path, network policies and/or rule-sets) for routing decisions. For L-FSN, we consider wireless link costs and cluster levels of gateways in addition to network policies. Since routers in BGP use the longest-prefix matching for forwarding packets, IP-based routing of BGP is not directly applicable for FSN. Gateways may not have IP-based addresses and cannot aggregate domain members by a suitable prefix. In addition, L-FSN targets rather a smaller network; therefore, forwarding packets according to unique gateway IDs is sufficient for FSN. We prefer to use geographical information along with gateway identifiers in order to aggregate island members. L-FSN consists of inter-island and intra-island querying protocols. Inter-island querying protocol of L-FSN establishes communication among islands according to a layered management of islands. Inter-island querying protocol enables packet routing regarding several path selection policies, such as the shortest path selection policy while considering privacy of the islands. By L-FSN, an island node can send a query packet directly to a specific island. For example, a miner can query the air pollution level in the next tunnel before relocating [3]. Depending on the application and use-case or management policy, each island can run an island-specific intra-island querying protocol for providing data indexing, caching, and replication functions. There are several in-network querying protocols in the WSNs literature to be adopted as an intra-island querying protocol of L-FSN.