In this paper, we develop a peer-to-peer (P2P) traffic identifier to facilitate quality of service (QoS) control in edge routers. Currently, since P2P applications consume a great percentage of Internet bandwidth, certain network optimization strategies are needed to improve the network performance. Traffic identification is the most important component that could be adopted in these optimization strategies. In this paper, we focus on developing a machine learning strategy to perform quick identification, and continuous tracking of flows associated with various P2P media streaming and file sharing applications. With the use of Random Forests (RF) and evaluated by using 10-fold cross validation, our method achieves greater than 98% accuracy rate and 89% precision rate of identifying the P2P flows, with less than 1% false positive rate. With the help of winner-take-all strategy, the generalization performance of using the RF built with data collected from one network to classify flows in other networks can achieve accuracy of being over 97%, with the precision being over 81% and the FP rate being below 2%.