LoadRunner IP 地址绑定到 vuser

LoadRunner IP address binding to vuser

在上次系统更新后,它要求每个用户使用唯一的 IP 地址进行身份验证。经过一番谷歌搜索后,我找到了 IP 向导和有关 IP Spoffing 的信息。现在 LR 提供了一个功能,为每个脚本 运行 设置随机 ip 地址到 vuser。 这是一个问题: 如何通过登录系统为vuser设置静态IP地址? 就像我有一个包含 ip 地址和登录名的池,当 vuser 登录到系统时,它已经从池中绑定了 ip。

通过使用以下函数,您可以获取和设置特定VUser 的IP 地址。这可以在 vuser_init() 或脚本中第一个动作的开头完成。

char *lr_get_vuser_ip( );

The lr_get_vuser_ip function returns the IPv4 address of a Vuser. When performing IP spoofing, each Vuser can use a different address. This function allows you to determine the current Vuser's IP address.

If the IP was set with the web_set_sockets_option function using the IP_ADDRESS_BY_INDEX option, lr_get_vuser_ip returns that IP.

To get an IPv6 address, use lr_get_attrib_string("ipv6")

Return Values

If this function succeeds , it returns a pointer to a string holding the IP address of the Vuser. If it fails, or if working with multiple IP addresses is disabled, it returns NULL.

int web_set_sockets_option( const char *option, const char *value );

Return Values

This function returns LR_PASS (0) on success, and LR_FAIL (1) on failure.

例子

web_set_sockets()函数可以这样使用:

 // Set current VUser IP address to 10.0.0.1
 web_set_sockets_option("USER_IP_ADDRESS", "10.0.0.1");