Sometimes an application running on a client (even a web broswer) will send the IP address of the client machine to the server at the Application layer, rather than the Network layer. This is surprisingly common with web-based apps designed to run on a company's intranet.

To make a BPM script accurately mimic a real user, the script should also send back the real IP address of the machine it is running from.

	char * vuserIpStr;
	web_set_sockets_option("IP_ADDRESS_BY_INDEX",  "1"); // Note that this forces the BPM to use the first NIC. This may cause confusion if the BPM has multiple NICs.
	vuserIpStr = (char *) lr_get_vuser_ip(); // 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. 

	if ( (vuserIpStr == NULL) || (strcmp(vuserIpStr,"") == 0) ) {
		lr_error_message("!!ERROR!!::Cannot get IP address for Virtual User.");
	} else {
		lr_output_message("NOTE::My Vuser IP address = [%s]", vuserIpStr);

	return 0;

Tech tips from JDS


How will we get the IP in case of WinInet replay mode?

Another code for get host IP !

char * VuserIP;

web_set_sockets_option(“IP_ADDRESS_BY_INDEX”, “1”);

VuserIP = (char*) lr_get_vuser_ip();

lr_output_message( “Etinte IP addressu = %s”, VuserIP);

Hi Sridhar,
yeah this is possibile if u set thru parametrization with list of possible Ip’s.

Is it possible to make a vuser to pick up a different IP for each iteration ? doing so can make a real unique client/user each iteration for the app..

Stuart Moncrieff

I have vague memories of playing with the Windows GetIpAddrTable() function, which can be found in Iphlpapi.dll.


An alternative would be to use the following code:

	int rc; 
	char *peer;

	rc = lrs_create_socket("socket1", "TCP", "LocalHost=:8888", LrsLastArg); 

	peer = lrs_get_socket_attrib("socket1", LOCAL_ADDRESS );

	lr_output_message("ip is %s", peer);

	return 0;

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.