Using RPC Counter

On the Windows 3.1 and Windows for Workgroups platforms, the RPC counter does not require any special setup.

To use RPC Counter on Windows NT Workstation and Windows 95 platforms

Set the following registry value to DWORD=1:

HKEY_LOCAL_MACHINE\Software\Microsoft\Exchange\Exchange Provider\RpcCounter

Restart all MAPI applications for the change to take effect.

Running Rpccnt.exe automatically sets the registry value to enable the RPC count.

Understanding the Fields of the RPC Counter

The RPC counter consists of the following nine fields, which indicate the number of RPCs generated for particular processes occurring on a Microsoft Exchange Server.

Field

Description

Total RPCs (IS+DS)

The number of RPCs going from all Microsoft Exchange clients on a given computer to all Microsoft Exchange Server computers they are connected to. This number includes RPCs to both the information store and the directory.

DS RPCs

The number of RPCs going to the directory. They are generated by MAPI calls related to address name resolution. All RPCs in this category need to be monitored carefully when optimizing MAPI clients. Note that DS RPCs are not counted on Windows 3.1 and Windows for Workgroups platforms.

IS RPCs

The total number of RPCs going to the information store. This number is the result of either MAPI calls accessing the message data or is generated automatically by the store provider code.

IS Bytes Out

The total number of bytes sent. It does not include the overhead of the RPC protocol. For example, the number reported by the network tools will be approximately 300 bytes higher per RPC.

IS Bytes In

The total number of bytes received. It does not include the overhead of the RPC protocol. For example, the number reported by the network tools will be approximately 300 bytes higher per RPC.

Progress RPCs (IS)

Indicates the RPCs generated automatically by the information store provider to monitor the progress of long operations.

Resent RPCs (IS)

Indicates the RPCs generated automatically by the information store provider if the RPC buffer is too small and the data needs to be resent.

Poll RPCs (IS)

Indicates the RPCs generated automatically by the information store provider to check for pending notification or to get the data after receiving a push notification. Indicates the RPCs generated directly by a MAPI call. This is the most important number to monitor when optimizing MAPI clients.


In addition, the RPC Counter dialog box displays an Auto Reset check box and a Reset Now button. The Auto Reset check box causes the counter data to be reset after four seconds of idle time. The Reset Now button resets the counter immediately.

Understanding RPC Counter Entry Points

When using the Rpccnt(16).exe sample application, the file calls the appropriate Emsmdb(32).dll entry points to obtain the counter data. The information in this section is provided if you need to call the entry points directly (for example, to integrate the RPC counter with other performance tools). The macro in Rpccnt.xls is an example of how to access the counter data from Visual Basic code.

The Emsmdb(32).dll file contains three entry points necessary for accessing RPC data. These entry points are the same for Windows 3.1, Windows for Workgroups, Windows NT Workstation, and Windows 95 platforms.

The three entry points are:

Examples

The following examples show the entry point declarations in both C and Visual Basic syntax:

C Syntax
SCODE FAR PASCAL ScStatOpen(void);
SCODE FAR PASCAL ScStatClose(void);
SCODE FAR PASCAL ScStatCollect(struct RPCStat *rgStat, ULONG *pcbStat);
Visual Basic Syntax
Declare Function ScStatOpen Lib "EMSMDB.DLL" () As Long
Declare Function ScStatClose Lib "EMSMDB.DLL" () As Long
Declare Function ScStatCollect Lib "EMSMDB.DLL" (ByRef rgStat As RPCStat, ByRef cbStat As Long) As Long

Because the data counting begins when ScStatOpen is called, a call to ScStatClose followed by ScStatOpen resets the counter. Because Windows NT Workstation and Windows 95 platforms have a per-instance data segment, you might have several counters counting independently. Windows 3.1 and Windows for Workgroups, however, have a shared data segment; therefore, resetting the counter is global to all instances.

Understanding the RPCStat Structure

The RPCStat structure contains the RPC counter values. These values are generated in the fields described previously in "Understanding the Fields of the RPC Counter." The RPCStat structure used by the entry points are:

C Syntax
struct RPCStat
{
 ULONG  cRPC;
 ULONG  cProgressRPC;
 ULONG  cResentRPC;
 ULONG  cPollRPC;
 ULONG  cbRPCOut;
 ULONG  cbRPCIn;
 ULONG  cDSARPC;
};
Visual Basic Syntax
Type RPCStat
 cRPC As Long
 cProgressRPC As Long
 cResentRPC As Long
 cPollRPC As Long
 cbRPCOut As Long
 cbRPCIn As Long
 cDSARPC As Long
End Type

The ScStatCollect entry point has a pointer as an argument to the RPCStat structure (allocated by the caller) and a pointer to a long variable containing the size of the RPCStat structure in bytes. On return, if there is no error (return value = 0), the RPCStat structure is updated with the counter values and the size variable is updated with the returned data size. If an error occurs (for example, "Out of memory"), the returned value is non-zero.