A crucial area of research is traffic classification, particularly in light of the advancements in machine learning in software-defined networking. Software-defined networks, which divide the control and data planes, can be automated and controlled by machine learning. Because traditional procedures could not keep up with the expanding use of encryption, the use of techniques for this purpose has increased. In this study, 15 features (the quantity of packets communicated, the average transmission time, and the number of instantly transmitted packets) were used to build traffic flows on the SDN for several protocols, including WWW, DNS, FTP, ICMP, P2P, and VOIP. A real-time dataset was produced by gathering data based on the features that were generated over the SDN controller in the physical network. We use the dataset to test and train a variety of machine learning models, including Random Forest, K Nearest Neighbor, Support Vector Machine, Logistic Regression, Decision Tree, and Naive Bayes. With a 99.8% accuracy rate, Decision Tree emerged as the most successful model for the traffic classification challenge. In order to provide the best classification performance with the lowest cost flow features for traffic classification in SDN, this approach has been identified as machine learning.