|
最近几天一直在做一个C/S模式客户端的测试,用Lr录制没有问题,但是脚本中有大家经常遇到的十六进制乱码问题,回放时遇到Mismatch问题,分析客户端和脚本发现客户端每次连接服务器会接收到一个动态分配的instanceId,位置在buf3,因此必须进行关联,问题是data.ws中的乱码分析和参数化还是有点困难,参数化的结果还是没有解决mismatch问题,而且lrs_output_message的输出也不对,实在很是困惑,希望遇到过这个问题的朋友可以解释一下,以后将这个案例详细说明,给大家做个资料。
脚本:
#include "lrs.h"
Action()
{
//lrs_set_receive_option(EndMarker, EndMarker_None);
// lrs_set_recv_timeout2(0,0);
/// lrs_set_receive_option(EndMarker, StringTerminator , "\r\n");
//lrs_set_receive_option(EndMarker, BinaryStringTerminator , "\\X00");
lrs_create_socket("socket0", "TCP", "RemoteHost=xxx.xxx.xxx.xxx:xxxx", LrsLastArg);
lrs_send("socket0", "buf0", LrsLastArg);
lrs_receive("socket0", "buf1", LrsLastArg);
lrs_close_socket("socket0");
lrs_create_socket("socket1", "TCP", "RemoteHost=xxx.xxx.xxx.xxx:xxxx", LrsLastArg);
lrs_send("socket1", "buf2", LrsLastArg);
lrs_receive("socket1", "buf3", LrsLastArg);
lrs_save_param("socket1","buf2","cctv",0,32);
lr_output_message ("param1: %s", lr_eval_string("<cctv>"));
lrs_close_socket("socket1");
lrs_create_socket("socket2", "TCP", "RemoteHost=xxx.xxx.xxx.xxx:xxxx", LrsLastArg);
lrs_send("socket2", "buf4", LrsLastArg);
lrs_receive("socket2", "buf5", LrsLastArg);
lrs_close_socket("socket2");
lrs_create_socket("socket3", "TCP", "RemoteHost=xxx.xxx.xxx.xxx:xxxx", LrsLastArg);
lrs_send("socket3", "buf6", LrsLastArg);
lrs_receive("socket3", "buf7", LrsLastArg);
lrs_close_socket("socket3");
lrs_create_socket("socket4", "TCP", "RemoteHost=xxx.xxx.xxx.xxx:xxxx", LrsLastArg);
lrs_send("socket4", "buf8", LrsLastArg);
lrs_receive("socket4", "buf9", LrsLastArg);
lrs_close_socket("socket4");
lrs_create_socket("socket5", "TCP", "RemoteHost=xxx.xxx.xxx.xxx:xxxx", LrsLastArg);
lrs_send("socket5", "buf10", LrsLastArg);
lrs_receive("socket5", "buf11", LrsLastArg);
lrs_close_socket("socket5");
return 0;
}
回放日志:
Action.c(16): lrs_create_socket(socket0, TCP, ...)
Action.c(18): lrs_send(socket0, buf0)
Action.c(20): lrs_receive(socket0, buf1)
Action.c(22): lrs_close_socket(socket0)
Action.c(25): lrs_create_socket(socket1, TCP, ...)
Action.c(28): lrs_send(socket1, buf2)
Action.c(31): lrs_receive(socket1, buf3)
Action.c(32): lrs_save_param(socket1, buf2, cctv, 0, 32)
Action.c(33): param1: NET@1999#01\x00\x00\x05\xe8\x03\x00\x00\x01\x00)\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
Action.c(35): lrs_close_socket(socket1)
Action.c(37): lrs_create_socket(socket2, TCP, ...)
Action.c(39): lrs_send(socket2, buf4)
Action.c(41): lrs_receive(socket2, buf5)
Action.c(41): Mismatch (expected 163 bytes, 71 bytes actually received)
Action.c(43): lrs_close_socket(socket2)
Action.c(45): lrs_create_socket(socket3, TCP, ...)
Action.c(47): lrs_send(socket3, buf6)
Action.c(49): lrs_receive(socket3, buf7)
Action.c(49): Mismatch (expected 5860 bytes, 71 bytes actually received)
Action.c(51): lrs_close_socket(socket3)
Action.c(53): lrs_create_socket(socket4, TCP, ...)
Action.c(55): lrs_send(socket4, buf8)
Action.c(57): lrs_receive(socket4, buf9)
Action.c(57): Mismatch (expected 159 bytes, 71 bytes actually received)
Action.c(59): lrs_close_socket(socket4)
Action.c(61): lrs_create_socket(socket5, TCP, ...)
Action.c(63): lrs_send(socket5, buf10)
Action.c(65): lrs_receive(socket5, buf11)
Action.c(65): Mismatch (expected 2367 bytes, 71 bytes actually received)
Action.c(67): lrs_close_socket(socket5)
end
录制日志:
/* New recording mechanism */
20:04:40.953 /* Start section (Action) */
20:04:48.593 /* WSAStartup(): process 2044 using flags 0 */
20:04:48.609 /* ReadCommWindowInfo: HttpInterceptMode = 0 */
20:04:48.625 /* socket(): created with handle: 2044:256, address format 2, type 1, protocol 6. */
20:04:48.703 /* connect(): socket 2044:256 tried to connect with family 2, port 7887, and address 0xdaf7b097. Return value: 0 */
20:04:48.703 /* setsockopt(): socket 2044:256, level: 0xffff, optname: 0x8, optval: 1 */
20:04:48.718 /* send(): 32 bytes were sent to socket 2044:256 using flags 0 */
(send_0, 32, 256)
"NET@1999#01"
"\x00"
"~"
"\x01\x02\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
20:04:48.812 /* recv(): 32 bytes were received from socket 2044:256 using flags 0 (32 were asked for) */
(recv_1, 32, 256)
"NET@1999#01"
"\x00\x00\x01\x02\x00\x00\x00\x01\x00"
"\r"
"\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff"
20:04:48.812 /* recv(): 13 bytes were received from socket 2044:256 using flags 0 (13 were asked for) */
(recv_2, 13, 256)
"6.1 3382 6 0"
"\x00"
20:04:48.812 /* setsockopt(): socket 2044:256, level: 0xffff, optname: 0x80, optval: 1 */
20:04:48.812 /* closesocket(): socket 2044:256 closed successfully */
20:04:48.890 /* socket(): created with handle: 2044:268, address format 2, type 1, protocol 6. */
20:04:49.000 /* connect(): socket 2044:268 tried to connect with family 2, port 7887, and address 0xdaf7b097. Return value: 0 */
20:04:49.000 /* setsockopt(): socket 2044:268, level: 0xffff, optname: 0x8, optval: 1 */
20:04:49.000 /* send(): 32 bytes were sent to socket 2044:268 using flags 0 */
(send_3, 32, 268)
"NET@1999#01"
"\x00\x00\x05\xe8\x03\x00\x00\x01\x00"
")"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
20:04:49.015 /* send(): 41 bytes were sent to socket 2044:268 using flags 0 */
(send_4, 41, 268)
"RPC@1999#03"
"\x00\x00\x00\x00\x01\x00\x00\x00\x00"
"\t"
"\x00\x00\x00"
"userID"
"\x00\x01"
"pwd"
"\x00"
20:04:49.390 /* recv(): 32 bytes were received from socket 2044:268 using flags 0 (32 were asked for) */
(recv_5, 32, 268)
"NET@1999#01"
"\x00\x00\x06\xe8\x03\x00\x00\x01\x00"
"\f"
"\x00\x00\x00\x00\x00\x00\x01\xff\xff\xff\xff"
20:04:49.406 /* recv(): 12 bytes were received from socket 2044:268 using flags 0 (12 were asked for) */
(recv_6, 12, 268)
"\x00\x00\x00\x00\xa3\x0f\x00\x01"
"\b"
"\x15"
"¨H"
参数化位置将revc_6替换为cctv,一个数字的文本
20:04:49.406 /* setsockopt(): socket 2044:268, level: 0xffff, optname: 0x80, optval: 1 */
20:04:49.406 /* closesocket(): socket 2044:268 closed successfully */
20:04:49.421 /* socket(): created with handle: 2044:268, address format 2, type 1, protocol 6. */
20:04:49.531 /* connect(): socket 2044:268 tried to connect with family 2, port 7887, and address 0xdaf7b097. Return value: 0 */
20:04:49.531 /* setsockopt(): socket 2044:268, level: 0xffff, optname: 0x8, optval: 1 */
20:04:49.546 /* send(): 32 bytes were sent to socket 2044:268 using flags 0 */
(send_7, 32, 268)
"NET@1999#01"
"\x00\x00\x05\xb8"
"\v"
"\x00\x00\x01\x00"
"I"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
20:04:49.546 /* send(): 73 bytes were sent to socket 2044:268 using flags 0 */
(send_8, 73, 268)
"RPC@1999#03"
"\x00\xa3\x0f\x00\x01"
"\b"
"\x15"
"¨H-"
"\x00\x00\x00\x01"
"TRS_InfoRadar_Channel"
"\x00\x00\x00\x01"
"MAX(LEVEL)"
"\x00\x01\x00\x01\x00\x01\x00\x01\x00\x00\x00\x00\x00"
20:04:49.921 /* recv(): 32 bytes were received from socket 2044:268 using flags 0 (32 were asked for) */
(recv_9, 32, 268)
"NET@1999#01"
"\x00\x00\x06\xb8"
"\v"
"\x00\x00\x01\x00\x83\x00\x00\x00\x00\x00\x00\x01\xff\xff\xff\xff"
20:05:22.421 /* closesocket(): socket 2044:268 closed successfully */ |
|