The energy consumption of network devices is a significant part of the network's energy costs. Recently, Software-Defined Networking (SDN) has been suggested as a suitable and stable solution to decrease energy consumption. The main concern is how to manage resources for optimum energy consumption in SDN. Hence, this paper proposes a binary linear programming model. This model manages (on or off devices) switches, controllers, and SDN links based on the number of flows at the network edge, the processing capability of the controllers, the distance between switches and controllers, and the traffic. Therefore, with this model, the lowest energy consumption, and the lowest delay of control packets is achieved. The results show that this model, on average, has saved 40% of energy consumption, and it has also had up to 80% decrement when there is less network traffic. In addition, this model has decreased 68% of the delay of controlling packets with 70% decrement in less traffic.