The invention discloses a message analysis-based protocol format automatic inferring method, which is a method used for analyzing the input and output messages of a protocol entity so as to infer the specific format of the protocol messages. The method comprises the following steps of: firstly, according to the displayable attribute of characters, segmenting the obtained network message in bytes, and carrying out primary clustering based on a format sequence presented by segmentation; secondly, carrying out multi-sequence comparison on the message samples with similar structure by taking the segment as a unit, realizing alignment and length unification of message segments, thereby mastering the basic structure of the message segments and obtaining the whole structure of the message; and finally, carrying out a semantic inferring phase, based on the structure of the message, according to the value and the change features of each field in the sample, following the identification strategies of various semantics, and using the semantic inferring flow of interval field, data field, serial number field, length field and format identifier field. The accuracy and the efficiency of semantic inferring are improved.