LoadRunner测试TCP协议服务器性能
作者:网络转载 发布时间:[ 2015/2/10 13:45:11 ] 推荐标签:性能测试工具 LoadRunner TCP协议
本文件包含了两种功能的函数:一个是如何生成guid,一个是如何替换字符串中的子串。
action.c
/*********************************************************************
* Created by Mercury Interactive Windows Sockets Recorder
*
* Created on: Tue Dec 30 16:04:06
*********************************************************************/
#include "lrs.h"
#include "def.h"
Action()
{
int sendLoginCount=0,sendCrossCount=0;
int loginIndex,loginIndex2;
char* clientId = guid_gen();
char clientId2[100];
char* clientId3;
int clientIdlen;
char* loginSrc = "<?xml version="1.0" encoding="UTF-8" ?> <Parament> "
" <ClientId>$ClientId</ClientId> "
" <ServerIP>$IP</ServerIP> "
" <ServerPort>$Port</ServerPort> "
" <Username></Username> "
" <Password></Password> "
"</Parament>";
char* loginStr;
int loginStrLen;
char* loginStrLenHex;
char loginStrLenStr[5];
char send_loginHeader[100]="\x12$Len\x00\x010";
char* send_loginHeaderf;
char send_loginStr[1500]="";
//添加路口相关字符串
char* crossSrc= "<?xml version="1.0" encoding="UTF-8" ?> <Parament> "
" <ClientId>$ClientId</ClientId> "
" <CrossId>$CrossId</CrossId> "
"</Parament>";
char* send_addCrossHeader = "\x12$Len\x00\x02";
char* crossId = lr_eval_string("<db_crossId>");
char* crossStr;
char send_crossStr[1700];
char crossStrLenStr[5];
int crossStrLen;
char* send_addCrossHeaderf;
int crossAddIndex,crossAddIndex2;
strcpy(clientId2,lr_eval_string(clientId));
clientId3 = clientId;
//登陆数据
loginStr = strreplace(loginStr,loginSrc,"$ClientId",clientId,strlen(loginSrc));
loginStr = strreplace(loginStr,loginStr,"$IP","127.0.0.1",strlen(loginStr));
loginStr = strreplace(loginStr,loginStr,"$Port","9300",strlen(loginStr));
lr_output_message("loginStr:%s",loginStr);
loginStrLen = strlen(loginStr)+1;
//lr_output_message("loginStrLen:%d",loginStrLen);
//itoa(loginStrLen,loginStrLenStr,16);
sprintf(loginStrLenStr, "%X", loginStrLen);
//lr_output_message("loginStrLenStr:%s",loginStrLenStr);
if(strlen(loginStrLenStr)==2)
{
char tmpH[5];
strcpy(tmpH,loginStrLenStr);
strcpy(loginStrLenStr,"\x00\x00\x00\x");
strcat(loginStrLenStr,tmpH);
}else{
char tmpH[5];
char tmpD[5];
strcpy(tmpH,loginStrLenStr);
strcpy(tmpH+1,"