z309466902 发表于 2012-11-13 17:13:19

sockets测试UDP协议ACK返回的一个问题,请各位大神帮忙看看

流程是:
1、客户端发起登录请求去获取随机数,UDP格式
2、服务器收到请求后,给客户端返回一个ACK(这个ACK响应是开发人员定义的)和一个401鉴权响应
3、客户端收到鉴权响应后,应该给服务返回一个ACK,表示收到,服务器收到这个ACK后,就不会再重复发送


问题:
1、我们怎么用Lr模拟我们发送给服务器的ACK,下面的脚本是我写的,但通过抓包查看,发现服务器要发送3次的随机数给客户端后,才会继续进行发送ACK的操作,请问这个问题怎么解决,万分感谢
抓包
U.........;.....Y<75558010312>{"sno":1,"timeStamp":"2012-11-13 01:06:55.832","userAccount":"75558010312"}
U................U....8....<.....c{"nonce":"3844628282","resultCode":401,"sno":1,"timeStamp":"2012-11-13 09:15:50","userAccount":""}
U....8....<.....c{"nonce":"3844628282","resultCode":401,"sno":1,"timeStamp":"2012-11-13 09:15:50","userAccount":""}
U....8....<.....c{"nonce":"3844628282","resultCode":401,"sno":1,"timeStamp":"2012-11-13 09:15:50","userAccount":""}

LR脚本
Action()
{
               lrs_create_socket("socket0", "UDP", "LocalHost=18998",LrsLastArg);

         lrs_send"buf0", "TargetSocket=10.137.86.5:8089", LrsLastArg
                lrs_set_recv_timeout2(5,0);

      lr_start_transaction("GetRamom");

      lrs_receive("socket0", "buf1", LrsLastArg);
      lrs_send("socket0","buf2", "TargetSocket=10.137.86.5:8089", LrsLastArg);
      lrs_save_searched_string("socket0",NULL,"RAMOM1","LB=nonce\":","RB=\"",3,1,-1);
      lrs_save_searched_string("socket0",NULL,"resultCode","LB=resultCode\"","RB=,",3,1,-1);

      if (strcmp(lr_eval_string("<resultCode>"),"401")==0) {
                lr_end_transaction("GetRamom", LR_PASS);
      }
      
      lr_output_message("resultCode is : %s",lr_eval_string("<resultCode>"));
      lr_output_message("RAMOM is : %s",lr_eval_string("<RAMOM1>"));
    return 0;
}


LR 获取随机数运行结果:
Action.c(23): Notify: Transaction "GetRamom" ended with "Pass" status (Duration: 11.0700 Wasted Time: 5.0000).
页: [1]
查看完整版本: sockets测试UDP协议ACK返回的一个问题,请各位大神帮忙看看