Unmanned Aerial Vehicles (UAVs) technology is evolving very quickly. New advancements in this important area of research have led more efficient and superior UAVs of all sizes, which have a vast amount of on-board command, control, processing, storage and networking capabilities. Such devices promise to be very useful and efficient in a wide variety of applications. In order to successfully and efficiently achieve their functions and accomplish their tasks, UAVs must communicate with each other using UAV-to-UAV (U2U) communication. They also must communicate with other systems using UAV-to-Infrastructure (U2I) communication. Furthermore, in addition to the numerous tasks and services that would be greatly improved using UAVs, these useful devices can be used to enhance the data collection process in wireless sensor networks (WSNs), which have a large number of environmental, military, and commercial monitoring and surveillance applications. In this paper, we offer an overview of UAV system services, functions, and requirements that are involved in the design of UAV-based systems at the various networking layers. We also present some of the various types of networking architectures, frameworks, and networking protocols that can be used for U2U and U2I communication. In addition, the paper outlines the services that can be performed by the middleware layer to provide increased networking system efficiency and seamless handling of communication between heterogeneous UAV nodes as well as ground and satellite communication units. In addition, we discuss the use of UAVs for data collection in WSNs. Such use of UAVs can be very effective in reducing WSN energy consumption, and communication interference, which can lead to a highly scalable and efficient networking framework.