RFC2544中有一个丢包率的概念,各种测试仪表厂商测试丢包率的实现都是依据这个RFC来做的。具体实现如下:
首先,以一定的速率发送数据包,在发送的数据包中特定字段打上特定的标记,比如数据结尾部分全部都是x1x1,然后发送这个数据包,在接收端查看收到的这些数据包的数量,这样,通过对比发送的特定数据包的数量和接收到的特定数据包的数量就可以算出丢包率了。理论上是一个平均值的概念。例如在1秒内发送1000个数据包,收到500个,那么丢包率应该是(1000-500)/1000=50%,发送仪表会自己计算一秒内发送的数据包。(当然,测试仪表会等待几秒,确认所有没有丢掉的数据包都到达了,这个可以自己定义,如果一个数据包过了100秒才到达,和丢了也没什么区别了哈)
另外,需要提醒你的是,现有测试丢包率的概念都是2层包或3层包,貌似没有去做更高层的包的丢包率,你说的按照ACK包来判断丢包,好像很不现实。而且你也应该知道,如果数据包存在ACK机制,肯定会涉及到重传,重传的数据包又怎么计算呢?
下面是RFC定义的原文,你可以看看
Frame loss rate
Objective: To determine the frame loss rate, as defined in RFC1242,
of a DUT throughout the entire range of input data rates and frame
sizes.
Procedure: Send a specific number of frames at a specific rate
through the DUT to be tested and count the frames that are
transmitted by the DUT. The frame loss rate at each point is
calculated using the following equation:
( ( input_count - output_count ) * 100 ) / input_count
The first trial SHOULD be run for the frame rate that corresponds to
100% of the maximum rate for the frame size on the input media.
Repeat the procedure for the rate that corresponds to 90% of the
maximum rate used and then for 80% of this rate. This sequence
SHOULD be continued (at reducing 10% intervals) until there are two
successive trials in which no frames are lost. The maximum
granularity of the trials MUST be 10% of the maximum rate, a finer
granularity is encouraged.
Reporting format: The results of the frame loss rate test SHOULD be
plotted as a graph. If this is done then the X axis MUST be the
input frame rate as a percent of the theoretical rate for the media
at the specific frame size. The Y axis MUST be the percent loss at
the particular input rate. The left end of the X axis and the bottom
of the Y axis MUST be 0 percent; the right end of the X axis and the
top of the Y axis MUST be 100 percent. Multiple lines on the graph
MAY used to report the frame loss rate for different frame sizes,
protocols, and types of data streams.
Note: See section 18 for the maximum frame rates that SHOULD be used.