Session Monitoring and Control (SMC)
This section contains the Application Programming Interface (API) for the Session Monitoring and Control. The Session Monitoring and Control APIs allow the user mode applications to obtain information about ICA sessions and/or exercise control over bandwidth used by ICA sessions.
The unit of measurement for all bandwidth readings is bits per sec.
Nomenclature
The following data types are assumed to be defined in the following sections:
- WCHAR, a 16 bit UNICODE character
- UINT32, a 32 bit unsigned integer
- UINT64, a 64 bit unsigned integer
Server functions
WFSmcGetVersionSupported
DWORD WINAPI WFSmcGetVersionSupported (
IN HANDLE hServer
OUT UINT32* pVersionSupported,
OUT UINT32* pFeaturesSupported
);
Description:
Returns the SMC API version number and the features supported on the current server. This API is supported only on the current server.
Parameters:
Parameter | Description |
---|---|
hServer | A handle to a server that is running CVAD Server. Specify WF_CURRENT_SERVER_HANDLE to use the current server. |
pVersionSupported | Address of a UINT32 which receives the API version number. The SMC API will be backward compatible with version numbers less than this value. The lowest version number is 1. |
pFeaturesSupported | Address of a UINT32 which receives a maskcontaining flags indicating which features of the API are supported. The features supported are dependent upon licensing conditions. The availability of each of the API functions in the SMC API set depends on the values returned through this parameter. The required compatibility list presented with each of the APIs indicates the flags required for that API to be exposed. These can be a combination of the following values: SMC_API_COMPATIBILITY_XP and SMC_API_COMPATIBILITY_XPE_FR1. |
Return values:
Value | Description |
---|---|
ERROR_SUCCESS | The function completed successfully. pVersionSupported points to a UINT32 containing the version number of the SMC API. pFeaturesSupported points to a UINT32 mask defining the feature level. |
ERROR_SERVICE_NOT_ACTIVE | A service that the dll depends on was not started, or is unavailable. |
ERROR_INVALID_PARAMETER | Either of the parameters was NULL. |
WFSmcGetServerData
DWORD WINAPI WFSmcGetServerData (
IN HANDLE hServer,
IN INT32 cbData,
OUT PWFSMC_SERVER_DATA pData,
IN UINT32 cbServerVCData,
OUT PWFSMC_SERVER_VC_DATA pServerVCData,
IN OUT UINT32 *pcVCs
);
Description:
Returns cumulative totals for the server. See the WFSMC_SERVER_DATA definition for details. This API is supported only on the current server.
Parameters:
Parameter | Description |
---|---|
hServer | A handle to a server that is running Citrix Virtual Apps and Desktops server. Specify WF_CURRENT_SERVER_HANDLE to use the current server. |
cbData | The size in bytes of the following structure used for server data. |
pData | Address of a PWFSMC_SERVER_DATA structure to be filled in by the call. |
cbServerVCData | The size, in bytes, of the following buffer used for an array of structures for the VC specific data. |
pServerVCData | Address of an array of WFSMC_SERVER_VC_DATA structs to be filled in by the call. |
pcVCs | [IN] Count of entries in the preceding array. [OUT] After the function has returned, this parameter contains the count of entries updated in the array pointed to by pServerVCData. If pServerVCData was NULL or the array was not large enough, the function returns ERROR_MORE_DATA and this parameter contains the required number of entries. |
Returns:
Parameter | Description |
---|---|
ERROR_SUCCESS | The function completed successfully. |
ERROR_NOT_ENOUGH_MEMORY | Not enough memory was available to process this request. |
ERROR_SERVICE_NOT_ACTIVE | A service that the dll depends on was not started, or is unavailable. |
ERROR_MORE_DATA | There was insufficient space to return all the Virtual Channel data, pcVCs now contains a count of how many there are. |
ERROR_INVALID_PARAMETER | Either cbData was less than the size of a Ctx_Smc_Server_Data structure, pData or pcVCs was NULL. |
ERROR_NOT_SUPPORTED | The version number passed in pData->VersionNumber is not supported. |
OTHER | Some other error occurred internally when trying to access the data. |
Session functions
WFSmcOpenSessionHandle
INT WINAPI WFSmcOpenSessionHandle(
IN HANDLE hServer,
IN UINT32 SessionId,
OUT PHANDLE phSession
);
Description:
Returns a handle to the caller which uniquely identifies a session in the context of this API set.
Parameters: |Parameter|Description| |—|—| |hServer | A handle to a server that is running CVAD Server. Specify WF_CURRENT_SERVER_HANDLE touse the current server.| | SessionId| Session Id of the session for which the handle is required.| |phSession | Address of a HANDLE, which receives a handle to the session. This handle is valid in the context of this API set. When the caller has finished with this handle, it should be closed by a call to the WFSmcCloseSessionHandle function.|
Returns:
Value | Description |
---|---|
ERROR_SUCCESS | The function completed successfully. The memory pointed at by the phSession parameter contains a valid handle. |
ERROR_SERVICE_NOT_ACTIVE | A service that the dll depends on was not started, or is unavailable. |
ERROR_INVALID_ACCESS | The specified connection was inaccessible. |
ERROR_INVALID_PARAMETER | A NULL value was passed as the phSession parameter. |
ERROR_NOT_ENOUGH_MEMORY | Not enough memory was available to process this request. |
WFSmcCloseSessionHandle
INT WINAPI WFSmcCloseSessionHandle(
IN HANDLE hServer,
IN HANDLE hSession
);
Description:
Invalidates a session handle, which was obtained through a previous call to the WFSmcOpenSessionHandle function. After a handle is invalidated, calls to the other functions in the API set returns ERROR_INVALID_HANDLE. This function should be called when a handle is no longer required since it allows the DLL to internally release resources used by the handle.
Parameters:
Parameter | Description |
---|---|
hServer | A handle to a server that is running Citrix Virtual Apps and Desktops server. Specify WF_CURRENT_SERVER_HANDLE to use the current server. |
hSession | Handle to invalidate. This handle must have been created by a call to the WFSmcOpenSessionHandle function. |
Returns:
Parameter | Description |
---|---|
ERROR_SUCCESS | The function completed successfully. |
ERROR_INVALID_HANDLE | The handle specified by the hSession parameter was invalid. |
WFSmcGetSessionVirtualChannelNames
INT WINAPI
WFSmcGetSessionVirtualChannelNames (
IN HANDLE hServer,
IN HANDLE hSession,
IN UINT32 cbSessionVCNames,
OUT PWF_SMC_SESSION_VC_NAME pSessionVCNames,
IN OUT UINT32* pcSessionVCNames
);
Description:
Returns the Virtual Channel names in use for a session. This API is supported only on the current server.
Parameters:
Parameter | Description |
---|---|
hServer | A handle to a server that is running Citrix Virtual Apps and Desktops Server. Specify WF_CURRENT_SERVER_HANDLE to use the current server. |
hSession | Handle to the session for which the data is required. This handle must have been obtained using a call to the WFSmcOpenSessionHandle function. |
cbSessionVCNames | The size in bytes of the buffer pointed at by pSessionVCNames used for an array of structures of VC specific data. |
pSessionVCNames | Address of an array of WF_SMC_SESSION_VC_NAME structs to be filled in by the call. |
pcSessionVCNames | [IN] Count of entries in the preceding array. [OUT] After the function has returned, this parameter contains the count of entries updated in the array pointed to by pSessionVCNames. If pSessionVCNames was NULL or the array was not large enough, the function returns ERROR_MORE_DATA and this parameter contains the required number of entries. |
Returns:
Value | Description |
---|---|
ERROR_SUCCESS | The function completed successfully. |
ERROR_CALL_NOT_IMPLEMENTED | A required entry in the Required Compatibility list wasn’t met, and the call has been disabled. |
ERROR_SERVICE_NOT_ACTIVE | A service that the dll depends on was not started, or is unavailable. |
ERROR_INVALID_DATA | The session is valid, but the virtual channel names for the session are not available. |
ERROR_MORE_DATA | The buffer pointed at by the pSessionVCNames was of insufficient size to store all the Virtual Channel names in use. |
ERROR_NOT_READY | The virtual channels for this session have not completed initialization yet. |
ERROR_INVALID_PARAMETER | An invalid parameter was passed. NULL is an invalid value for the pcSessionVCNames parameter. |
ERROR_INVALID_HANDLE | The session handle specified by the hSession parameter is invalid. |
Remarks
Set the VersionNumber data member of structure WF_SMC_SESSION_VC_NAME = SMC_STRUCTURE_VERSION_V1 before calling the API
WFSmcGetSessionData
INT WINAPI WFSmcGetSessionData (
IN HANDLE hServer,
IN HANDLE hSession,
IN UINT32 cbData,
OUT PWF_SMC_SESSION_DATA pData,
IN UINT32 cbVCData,
OUT PWF_SMC_SESSION_VC_DATA pVCData,
IN OUT UINT32* pcVC
);
Description:
Returns the bandwidth usage, compression ratios and latency values for the session, as well as the bandwidth used by the virtual channels in the session if required. The bandwidth usage for the virtual channels is returned as an array of WFSmc_Session_VC_Data structs. Each entry in the array corresponds to the virtual channel returned by a call to the WFSmcGetSessionVirtualChannelNames function. This API is supported only on the current server.
Parameters:
Parameter | Description |
---|---|
hServer | A handle to a server that is running Citrix Virtual Apps and Desktops server. Specify WF_CURRENT_SERVER_HANDLE to use the current server. |
hSession | Handle to the session for which the data is required. This handle must have been obtained using a call to the WFSmcOpenSessionHandle function. |
cbData | The size in bytes of the following structure. |
pData | Address of a WF_SMC_SESSION_DATA structure to return session counters in. Currently, the VersionNumber member of this structure must contain 1. |
cbVCData | The size in bytes of the buffer containing the array of WF_SMC_SESSION_VC_DATA structures. |
pVCData | Address of an array of WF_SMC_SESSION_VC_DATA structs to be filled in by the call. |
pcVC | [IN] Count of entries in the preceding array. [OUT] After the function has returned, this parameter contains the count of entries updated in the array pointed to by pVCData. If pVCData was NULL, or the array was not large enough, the function returns ERROR_MORE_DATA, which contains the required number of entries. |
Returns:
Value | Description |
---|---|
ERROR_SUCCESS | The function completed successfully. |
ERROR_CALL_NOT_IMPLEMENTED | A required entry in the Required Compatibility list wasn’t met, and the call has been disabled. |
ERROR_SERVICE_NOT_ACTIVE | A service that the dll depends on was not started, or is unavailable. |
ERROR_MORE_DATA | There was insufficient space to return all the Virtual Channel data, pcVC now contains a count of how many there are. |
ERROR_INVALID_HANDLE | The handle specified by the hSession parameter is invalid. |
ERROR_INVALID_PARAMETER | Either cbData was less than the size of a WFSMC_SESSION_DATA structure, pData or pcVC was NULL. |
ERROR_NOT_SUPPORTED | The version number passed in pData->VersionNumber is not supported. |
Remarks
Set the VersionNumber data member of structures WF_SMC_SESSION_VC_NAME & WF_SMC_SESSION_DATA = SMC_STRUCTURE_VERSION_V1 before calling the API
WFSmcGetSessionDataV2
INT WINAPI WFSmcGetSessionDataV2 (
IN HANDLE hServer,
IN HANDLE hSession,
IN UINT32 cbData,
OUT pCtx_Smc_Session_Data_V2 pData,
IN UINT32 cbVCData,
OUT pCtx_Smc_Session_VC_Data_V2 pVCData,
IN OUT UINT32* pcVC
);
Description:
Returns the bandwidth usage, compression ratios and latency values for the session, as well as the bandwidth used by the virtual channels in the session if required. The bandwidth usage for the virtual channels is returned as an array of Ctx_Smc_Session_VC_Data_V2 structures. Each entry in the array corresponds to the virtual channel returned by a call to the WFSmcGetSessionVirtualChannelNames function. This API is supported only on the current server.
This api returns Ctx_Smc_Session_Data_V2 per connection. As per multistream ICA, we can have 4 connections per session.
Parameters:
Parameter | Value |
---|---|
hServer | A handle to a server that is running Citrix Virtual Apps and Desktops server. Specify WF_CURRENT_SERVER_HANDLE to use the current server. |
hSession | Handle to the session for which the data is required. This handle must have been obtained using a call to the WFSmcOpenSessionHandle function. |
cbData | The size in bytes of the following structure. |
pData | Address of a pCtx_Smc_Session_Data_V2 array of size 4 to return session counters in. Currently, the VersionNumber member of this structure must contain 2. |
cbVCData | The size in bytes of the buffer containing the array of WF_SMC_SESSION_VC_DATA structures. |
pVCData | Address of an array of Ctx_Smc_Session_VC_Data_V2 structs to be filled in by the call. |
pcVC | [IN] Count of entries in the preceding array. [OUT] After the function has returned, this parameter contains the count of entries updated in the array pointed to by pVCData. If pVCData was NULL, or the array was not large enough, the function returns ERROR_MORE_DATA, which contains the required number of entries. |
Returns:
Value | Description |
---|---|
ERROR_SUCCESS | The function completed successfully. |
ERROR_CALL_NOT_IMPLEMENTED | A required entry in the Required Compatibility list wasn’t met, and the call has been disabled. |
ERROR_SERVICE_NOT_ACTIVE | A service that the dll depends on was not started, or is unavailable. |
ERROR_MORE_DATA | There was insufficient space to return all the Virtual Channel data, pcVC now contains a count of how many there are. |
ERROR_INVALID_HANDLE | The handle specified by the hSession parameter is invalid. |
ERROR_INVALID_PARAMETER | Either cbData was less than the size of a WFSMC_SESSION_DATA structure, pData or pcVC was NULL. |
ERROR_NOT_SUPPORTED | The version number passed in pData->VersionNumber is not supported. |
Remarks
Set the VersionNumber data member of structures CTX_SMC_SESSION_DATA_V2 & CTX_SMC_SESSION_VC_DATA_V2 = SMC_STRUCTURE_VERSION_V2 before calling the API
WFSmcGetSessionLatencyData
INT WINAPI WFSmcGetSessionLatencyData {
IN HANDLE hServer,
IN HANDLE hSession,
OUT UINT32* pLastLatency,
OUT UINT32* pAverageLatency,
OUT UINT32* pRoundTripDeviation,
OUT UINT32* pTickCountLastUpdateTime
);
Description:
Returns the latency information for a session, a NULL pointer for any of the UINT32 pointers is ignored. This API is supported only on the current server.
Parameters:
Parameter | Description |
---|---|
hServer | A handle to a server that is running Citrix Virtual Apps and Desktops server. Specify WF_CURRENT_SERVER_HANDLE to use the current server. |
hSession | Handle to the session for which the data is required. This handle must have been obtained using a call to the WFSmcOpenSessionHandle function. |
pLastLatency | Address of a UINT32 which receives the value of the last recorded latency reading (ms). |
pAverageLatency | Address of a UINT32 which receives the value of the average latency over the life of the session (ms). |
pRoundTripDeviation | Address of a UINT32 which receives the round trip deviation for this session. |
pTickCountLastUpdateTime | Address of a UINT32 which receives the tick count of the last update time for the latency data. |
Returns:
Value | Description |
---|---|
ERROR_SUCCESS | The function completed successfully. |
ERROR_CALL_NOT_IMPLEMENTED | A required entry in the required compatibility list wasn’t met, and the call has been disabled. |
ERROR_SERVICE_NOT_ACTIVE | A service that the dll depends on was not started, or is unavailable. |
ERROR_INVALID_HANDLE | The handle specified by the hSession parameter is invalid. |
ERROR_NOT_READY | Latency information is not available for this session. Try again later. |
Remarks:
Not all ICA sessions support gathering of latency information. Only those clients with a version number of 6.0.910 or later, support gathering of latency information. In addition, depending on the setting used on the client for mouse feedback, the latency information for some clients will take a longer time to become available than for other clients.
WFSmcGetSessionBandwidthLimits
INT WINAPI WFSmcGetSessionBandwidthLimits (
IN HANDLE hServer,
IN HANDLE hSession,
IN UINT32 cEntries,
IN UINT32* pVCIDs,
OUT UINT32* pVCLimits
);
Description:
Returns the bandwidth limit settings for a session. This API is supported only on the current server.
Parameters:
Parameter | Description |
---|---|
hServer | A handle to a server that is running Citrix Virtual Apps and Desktops server. Specify WF_CURRENT_SERVER_HANDLE to use the current server. |
hSession | Handle to the session for which the data is required. This handle must have been obtained using a call to the WFSmcOpenSessionHandle function. |
cEntries | Count of entries in the array pointed at by pVCIDs. |
pVCIDs | Pointer to an array of ids of size cEntries, containing the ids of the VCs for which bandwidth limits are required. |
pVCLimits | Pointer to an array of UINT32 in which to return the bandwidth limit values that match the Ids passed in pVCIDs. Bandwidth limits are expressed in kilobits per second. |
Returns:
Value | Description |
---|---|
ERROR_SUCCESS | The function completed successfully. |
ERROR_CALL_NOT_IMPLEMENTED | A required entry in the Required Compatibility list wasn’t met, and the call has been disabled. |
ERROR_SERVICE_NOT_ACTIVE | A service that the dll depends on was not started, or is unavailable. |
ERROR_INVALID_PARAMETER | Either one or both of the pointers pVCIDs or pVCLimits is NULL. |
ERROR_INVALID_DATA | One or more of the ids in the array pointed to by pVCIDs does not match a known ID. |
ERROR_INVALID_HANDLE | The handle specified by the hSession parameter is invalid. |
Remarks:
The bandwidth limits for one or more VCs may be requested by the call. The cEntries specifies how many. The IDs must match the values obtained by a call to WFSmcGetSessionVirtualChannelNames() with the exception that an ID value of 0xFFFFFFFF specifies the bandwidth limit of the whole session.
WFSmcSetSessionBandwidthLimits
INT WINAPI WFSmcSetSessionBandwidthLimits (
IN HANDLE hServer,
IN HANDLE hSession,
IN UINT32 cEntries,
IN UINT32* pVCIDs,
IN UINT32* pVCLimits
);
Description:
Sets the bandwidth limits for a session. This API is supported only on the current server.
Parameters:
Parameter | Description |
---|---|
hServer | A handle to a server that is running Citrix Virtual Apps and Desktops server. Specify WF_CURRENT_SERVER_HANDLE to use the current server. |
hSession | Handle to the session for which the data is required to set. This handle must have been obtained using a call to the WFSmcOpenSessionHandle function. |
CEntries | Count of entries in the array pointed at by pVCIDs. |
pVCIDs | Pointer to an array of ids of size cEntries, containing the ids of the VCs for which bandwidth limits are required. |
pVCLimits | Pointer to an array of UINT32 in which to return the bandwidth limit values that match the IDs passed in pVCIDs. Bandwidth limits are expressed in kilobits per second. |
Returns:
Value | Description |
---|---|
ERROR_SUCCESS | The function completed successfully. |
ERROR_CALL_NOT_IMPLEMENTED | A required entry in the required compatibility list wasn’t met, and the call has been disabled. |
ERROR_SERVICE_NOT_ACTIVE | A service that the dll depends on was not started, or is unavailable. |
ERROR_INVALID_PARAMETER | Either the pointer pVCIDs or pVCLimits is NULL. |
ERROR_INVALID_DATA | One or more of the ids in the array pointed to by pVCIDs does not match the known |
ERROR_INVALID_HANDLE | The handle specified by the hSession parameter is invalid. |
OTHER | There was some other error internally when trying to set the limits. |
Remarks:
The bandwidth limits for one or more VCs may be set by the call. The cEntries specifies how many. The IDs must match the values obtained by a call to WFSmcGetSessionVirtualChannelNames() with the exception that an ID value of 0xFFFFFFFF specifies the bandwidth limit of the whole session.
WFSmcGetSessionPriorities
INT WINAPI WFSmcGetSessionPriorities(
IN HANDLE hServer,
IN HANDLE hSession,
IN UINT32 cEntries,
IN UINT32* pVCIDs,
OUT UINT32* pVCPriorities
);
Description:
Returns the VC priority settings for this session. This API is supported only on the current server.
Where,
Priorities are from the set
# define CTX_SESSION_VC_PRIORITY_HIGHEST 0
# define CTX_SESSION_VC_PRIORITY_HIGH 1
# define CTX_SESSION_VC_PRIORITY_NORMAL 2
# define CTX_SESSION_VC_PRIORITY_LOW 3
<!--NeedCopy-->
Parameters:
Parameter | Description |
---|---|
hServer | A handle to a server that is running Citrix Virtual Apps and Desktops server. Specify WF_CURRENT_SERVER_HANDLE to use the current server. |
hSession | Handle to the session for which the data is required. This handle should have been obtained using a call to the WFSmcOpenSessionHandle function. |
cEntries | Count of entries in the array pointed at by pVCIDs |
pVCIDs | Pointer to an array of ids of size cEntries, containing the IDs of the VCs for which priority settings are required. |
pVCPriorities | Pointer to an array of UINT32 in which to return the VC priority values that match the IDs passed in pVCIDs. |
Returns:
Value | Description |
---|---|
ERROR_SUCCESS | The function completed successfully. |
ERROR_CALL_NOT_IMPLEMENTED | A required entry in the required compatibility list wasn’t met, and the call has been disabled. |
ERROR_SERVICE_NOT_ACTIVE | A service that the dll depends on was not started, or is unavailable. |
ERROR_INVALID_PARAMETER | Either the pointer pVCIDs or pVCPriorities is NULL. |
ERROR_INVALID_DATA | One or more of the ids in the array pointed to by pVCIDs does not match the known VCs. |
ERROR_INVALID_HANDLE | The handle specified by the hSession parameter is invalid. |
Remarks
The priorities for one or more VCs may be requested by the call. The cEntries specifies how many. The IDs must match the values obtained by a call to WFSmcGetSessionVirtualChannelNames().
WFSmcSetSessionPriorities
INT WINAPI
WFSmcSetSessionPriorities(
IN HANDLE hServer,
IN HANDLE hSession,
IN UINT32 cEntries,
IN UINT32* pVCIDs,
IN UINT32* pVCPriorities
);
Description:
Sets the VC priority settings for this session. This API is supported only on the current server.
Where,Priorities are from the set
# define CTX_SESSION_VC_PRIORITY_HIGHEST 0
# define CTX_SESSION_VC_PRIORITY_HIGH 1
# define CTX_SESSION_VC_PRIORITY_NORMAL 2
# define CTX_SESSION_VC_PRIORITY_LOW 3
<!--NeedCopy-->
Parameters:
Parameter | Description |
---|---|
hServer | A handle to a server that is running Citrix Virtual Apps and Desktops server. Specify WF_CURRENT_SERVER_HANDLE to use the current server. |
hSession | Handle to the session for which the data is required. This handle should have been obtained using a call to the WFSmcOpenSessionHandle function. |
cEntries | Count of entries in the array pointed at by pVCIDs |
pVCIDs | Pointer to an array of IDs of size cEntries, containing the IDs of the VCs for which priorities are to be set. |
pVCPriorities | Pointer to an array of UINT32 containing the priority values to be set for the IDs passed in pVCIDs. |
Returns:
Value | Description |
---|---|
ERROR_SUCCESS | The function completed successfully. |
ERROR_CALL_NOT_IMPLEMENTED | A required entry in the Required Compatibility list wasn’t met, and the call has been disabled. |
ERROR_SERVICE_NOT_ACTIVE | A service that the dll depends on was not started, or is unavailable. |
ERROR_INVALID_PARAMETER | Either the pointer pVCIDs or pVCPriorities is NULL. |
ERROR_INVALID_DATA | One or more of the IDs in the array pointed to by pVCIDs does not match the known VCs or a priority in pVCPriorities is out of range. |
ERROR_INVALID_HANDLE | The handle specified by the hSession parameter is invalid |
Other | There was some other error internally when trying to set the priorities. |
Required compatibility
SMC_API_COMPATIBILITY_XPE_FR1
Remarks:
The priorities for one or more VCs may be set by the call. The cEntries specifies how many. The IDs must match the values obtained by a call to WFSmcGetSessionVirtualChannelNames().
In this article
- Nomenclature
- Server functions
- WFSmcGetVersionSupported
- WFSmcGetServerData
- Session functions
- WFSmcOpenSessionHandle
- WFSmcCloseSessionHandle
- WFSmcGetSessionVirtualChannelNames
- WFSmcGetSessionData
- WFSmcGetSessionDataV2
- WFSmcGetSessionLatencyData
- WFSmcGetSessionBandwidthLimits
- WFSmcSetSessionBandwidthLimits
- WFSmcGetSessionPriorities
- WFSmcSetSessionPriorities
- Required compatibility