5G LAN uses dense networking technology. Through the multi-layer heterogeneous network composed of macro cell base station, Pico cell base station, micro cell base station and other low-power small base stations, it can effectively improve the network capacity, enhance indoor coverage, and fill the blind. However, due to the complexity and variety of signaling interaction in the network, the signaling load of the network will increase exponentially in the super dense network scenario, which will consume a lot of resources and also produce delay. Therefore, this paper proposes a networking scheme based on software defined network, which separates the control and forwarding of small base stations, effectively alleviates the system pressure and shortens the system delay. In this paper, the multi factor iterative optimization algorithm (MFIOA) is proposed, which uses SDN architecture. The master node can obtain the environment information of each node to construct the clustering routing. The factors that affect the node as the cluster head include the residual energy of the node, the distance between the node and other nodes, and the number of adjacent nodes. The algorithm integrates the above conditions to achieve clustering routing and achieve more uniform clustering. The simulation results show that the proposed algorithm is superior to other common algorithms in terms of network residual energy, number of remaining nodes and network lifetime.