lewtone 发表于 2016-7-13 11:31:04

基于RTMP协议的性能测试

本帖最后由 lewtone 于 2016-7-13 11:32 编辑

最近公司要测试流媒体性能,第一次接触,网上资料也很少,只有相互抄来抄去的4个函数介绍,研究2天,测试如下;
1.RTMP介绍略
flex_rtmp_connectConnects a client to an RTMP server and sets connection options.
flex_rtmp_disconnectDisconnects a client from an RTMP server.
flex_rtmp_sendSends messages to an RTMP server.
flex_rtmp_receiveReceives responses from an RTMP server
2.制作测试脚本:测试协议选择Flex协议,Flex协议对RTMP支持;
配置协议:1.Run-times Settings(F4)-Flex-RTMP;在close all open RTMP*****选择,若不选择批量跑会报错【这个设置操作上应该等于flex_rtmp_disconnect函数】;
                2.TOOLS-Recording Options(crtl+F7)-NetWork-Port Mapping 选择Socket level data 或者Soket level data and WinNet level data;
               RTMP是通过1935端口建立的收发连接;
                3.在LR帮助文档描述还需要设置下面内容,设置收发连接的字节;
In order to enable RTMP simulation, you must configure the recording options for the Flex protocol.
To enable RTMP:
1 Open the Recording Options dialog box by selecting Tools > Recording Options or clicking the Options button in the Start Recording dialog box.
2 In the Network > Port Mapping node click Options.
3 Set the Send-Receive buffer size threshold to 1500.

我理解应该是RTMP握手及后续请求每次是1536个字节
http://baike.baidu.com/link?url=ZgaveTlLQ_hL5XMmgRBBgOsYbNPrVedUhBSOgv7R2kkvqEvqIibffXu-TrsmNArnpK89ozeJf3JxvHbMvtZzIq 握手及请求应答介绍

3.录制脚本;填写地址,点击播放,制作脚本
flex_rtmp_connect("connect_step0",
"Host=10.200.4.61:1935",
"Snapshot=tRTMP1.inf",
"ConnectionID=12",
MESSAGE,
"ChannelID=3",
"DataType=invoke",
"StreamID=0",
"Argument=<arguments><string>connect</string><number>1</number><object>"
"<string name=\"app\">test1/</string><string name=\"flashVer\">WIN 22,0"
",0,192</string><string name=\"swfUrl\">http://10.200.4.61:8880/"
"video.js/dist/video-js.swf</string><string name=\"tcUrl\">rtmp://"
"10.200.4.61:1935/test1/</string><boolean name=\"fpad\">false</boolean>"
"<number name=\"capabilities\">239</number><number name=\"audioCodecs\""
">3575</number><number name=\"videoCodecs\">252</number><number name=\""
"videoFunction\">1</number><string name=\"pageUrl\">http://10.200.4.61"
":8880/video.js/test/i:qndex.h5_4.html</string><number name=\""
"objectEncoding\">3</number></object></arguments>",
LAST);
flex_rtmp_receive("recv_step0",
"ConnectionID=12",
"Snapshot=tRTMP2.inf",
CHANNEL,
"ChannelID=2",
LAST);
flex_rtmp_receive("recv_step1",
"ConnectionID=12",
"Snapshot=tRTMP3.inf",
CHANNEL,
"ChannelID=2",
CHANNEL,
"ChannelID=2",
CHANNEL,
"ChannelID=3",
LAST);
flex_rtmp_send("send_step0",
"ConnectionID=12",
"Snapshot=tRTMP4.inf",
MESSAGE,
"ChannelID=2",
"DataType=server bw",
"StreamID=0",
"Argument=<arguments><xmlData><!]></"
"xmlData></arguments>",
LAST);
flex_rtmp_send("send_step1",
"ConnectionID=12",
"Snapshot=tRTMP5.inf",
MESSAGE,
"ChannelID=3",
"DataType=flex message",
"StreamID=0",
"Argument=<arguments><string>createStream</string><number>2</number>"
"<null/></arguments>",
LAST);
flex_rtmp_send("send_step2",
"ConnectionID=12",
"Snapshot=tRTMP6.inf",
MESSAGE,
"ChannelID=2",
"DataType=ping",
"StreamID=0",
"Argument=<arguments><xmlData><![CDATA[<string"
">\\x00\\x03\\x00\\x00\\x00\\x00\\x00\\x00\\x03\\xe8</string>]]></"
"xmlData></arguments>",
LAST);
flex_rtmp_receive("recv_step2",
"ConnectionID=12",
"Snapshot=tRTMP7.inf",
CHANNEL,
"ChannelID=3",
LAST);
flex_rtmp_disconnect("disconnect_step0",
      "ConnectionID=12",
LAST);//手动添加disconnect,录制时候一定会产生这个脚本

到此一个脚本部分内容如上,,脚本内容也比较简单,不过LR帮助文档也没有相关介绍,如果自己手动写不一定写出来;
需要注意是,一个音频文件脚本会建立几百次甚至上千次receive,因此脚本中wasted time较高,在批量运行也会包含浪费时间
Action.c(3181): Notify: Transaction "音频" ended with "Pass" status (Duration: 74.9486 Wasted Time: 9.3849).

以上只代表本人观点!

lewtone 发表于 2016-7-13 11:49:47

测试后日志统计可能会用到一些Linux命令,我的是基于Linux
awk '{ print $14,$15 }' access.log.bak > access.log.bak.ms//将日志中的列打印到新的文件
sed -i "s/(//g" access.log.bak.ms.0712 //日志记录的时间带单位的,我把这些去掉,
cat access.log.bak.ms.0712|awk '{sum+=$1} END {print "Average = ", sum/NR}';//其实如果括号在后面不用去也可以计算平均值,这个是计算第一列平均值
(1
(2像这种括号在前计算不了平均值,需要去掉括号

lsekfe 发表于 2016-7-13 13:25:06

支持原创分享~
页: [1]
查看完整版本: 基于RTMP协议的性能测试