With the increasing advancement in the applications of the Internet of Things (IoT), the integrated Cloud Computing (CC) faces numerous threats such as performance, security, latency, and network breakdown. With the discovery of Fog Computing these issues are addressed by taking CC nearer to the Internet of Things (IoT). The key functionality of the fog is to provide the data generated by the IoT devices near the edge. Processing of the data and data storage is done locally at the fog node rather than moving the information to the cloud server. In comparison with the cloud, Fog Computing delivers services with high quality and quick response time. Hence, Fog Computing might be the optimal option to allow the Internet of Things to deliver an efficient and highly secured service to numerous IoT clients. It allows the administration of the services and resource provisioning outside CC, nearer to devices, at the network edge, or ultimately at places specified by Service Level Agreements (SLA’s). Fog Computing is not a replacement to CC, but a prevailing component. It allows the processing of the information at the edge though still delivering the option to connect with the data center of the cloud. In this paper, we put forward various computing paradigms, features of fog computing, an in-depth reference architecture of fog with its various levels, a detailed analysis of fog with IoT, various fog system algorithms and also systematically examine the challenges in Fog Computing which acts as a middle layer between IoT sensors or devices and data centers of the cloud.