The 5th/B5Gth/6th generation mobile networks (5G for short) virtualize a physical device into n virtual components to support packet transmission, n >= 1. 5G further classifies a network into three major categories, namely uRLLC (ultra-Reliable and Low Latency Communications), eMBB (enhanced Mobile Broadband), and mMTC (massive Machine Type Communications), because 5G would like to improve the shortcomings of 4G-network transmission, including not transmitted fast enough and no application differentiation among applications. Also, network slicing is a hot research topic since different slices can support different requirements of different applications. However, network slicing currently has not achieved its mature stage. Many efforts are required to define and implement network slicing. Therefore, in this study, we propose an UDF slicing approach by virtualizing a physical switch into many virtual switches with which to transmit data so that each virtual switch can define its own transmission requirements, i.e., latency, data delivery speed, and bandwidth along the best routing path.