The invention discloses an IP data packet identification method and a gateway, which are designed to solve the problems that the existing IP data packet identification method and the gateway are low in accuracy rate, low in efficiency and large in time
delay. The IP data packet identification method comprises the following steps: extracting the front N bytes of data of an IP data packet
application layer, and converting the extracted bytes into a
frequency domain signal through Fourier transformation to obtain a characteristic string of the
frequency domain, and sorting the IP data packets according to the characteristic string by a
machine learning
algorithm. The gateway in the invention at least comprises an identifying unit which comprises an extracting module, a Fourier transforming module and a sorting module which are connected orderly. The IP data packet identification method and the gateway have the advantages of high accuracy rate, high efficiency and easy implementation.