IoT is a new communication paradigm that gains a very high importance in the past few years. Fog computing is a form of edge computing that is developed to provide the computing, storage and management capabilities near to users. Employing Fog computing in IoT networks as an intermediate layer between IoT devices and the remote cloud becomes a demand to make use of the edge computing benefits. In this work, we provide a framework for IoT system structure that employs an edge computing layer of Fog nodes. The system employs SDN network with a centralized controller and distributed OpenFlow switches; these switches are enabled with limited computing and processing capabilities. The network is operated based on a data offloading algorithm, that allocates certain processing and computing tasks to some OpenFlow switches that has unused resources. The proposed work achieves various benefits to the IoT network such as the latency reduction and higher efficiency of resources utilization. We perform an experiment over a developed testbed to validate the proposed system and results show that the proposed system achieves higher efficiency in terms of latency and resource utilization.