Network-on-chip (NoC) has been proposed as a better interconnection method than the bus architecture. Recently, a large number of routing algorithms have been proposed to improve the network performance. They usually show their benefits under particular traffic patterns. However, traffic patterns are generally unknown in advance and vary according to the application due to the behavioral diversity between inter-core and memory access communications. In this paper, a local traffic pattern detecting mechanism is proposed to detect the current traffic patterns including uniform, transpose, hotspot and real workloads, and then the routing algorithm will be switched to the most suitable one according to the detection result. Experimental results show that the traffic pattern can be accurately detected. For the hotspot traffic pattern, the success rate of the detector can reach up to 100 percent when the hotspot percentage is larger than 8. With the help of the proposed traffic-robust routing algorithm, the network can always work with a more suitable routing algorithm and achieve better performance.