Table of Contents

Special Events and Metrics

Special events

You can use special events in base class SmppClientBase for tracking PDUs:

  • with the event evPduReceiving you can monitor all incoming PDUs.
  • event evPduSending is invoked before sending the PDU to network.

Metrics

To monitor SmppClient or SmppServerClient performance you can use Metrics property. It contains many useful values calculated automatically.

The ISmppClientMetrics type of the Metrics property has the following structure:

  • Sent - Gets the metrics for messages sent.
    • InQueue - Number of messages stored in the queue (awaiting to be sent).
    • Total - Total number of messages sent.
    • Requests
      • Total - Total number of requests sent.
      • PerSecond - Transferring speed for the last second. Messages per second.
      • AvgPerSecond - Average speed since last Reset. Messages per second.
      • WaitingForResponse - Gets number of request PDUs that didn't receive a response with the same sequence number.
    • Responses
      • Total - Total number of responses sent.
      • PerSecond - Transferring speed for the last second. Messages per second.
      • AvgPerSecond - Average speed since last Reset. Messages per second.
  • Received - Gets the metrics for messages received.
    • InQueue - Number of requests stored in the queue (received but not processed in worker threads).
    • Total - Total number of messages received.
    • Requests
      • Total - Total number of requests received.
      • PerSecond - Transferring speed for the last second. Messages per second.
      • AvgPerSecond - Average speed since last Reset. Messages per second.
      • WaitingForResponse - Number of request PDUs that didn't processed. Same as Received.InQueue.
    • Responses
      • Total - Total number of responses received.
      • PerSecond - Transferring speed for the last second. Messages per second.
      • AvgPerSecond - Average speed since last Reset. Messages per second.

All properties in the metrics objects are constantly changed during message transferring. If you want to fix the metric's value for further analysis, you can use the method Snapshot().

var clientMetrics = _client.Metrics.Snapshot();

This method copies all current values to new metrics object where the values won't change anymore. The same Snapshot method is also available for child properties, for example:

var requestMetrics = clientMetrics.Sent.Requests.Snapshot();

or

var responseMetrics = clientMetrics.Received.Responses.Snapshot();

You can also use Reset() method for the cases when you need to analyze some part of the process and begin to watch values from zero. The Reset() method is also available for each child metric object.

// start sent requests metrics from zero
_client.Metrics.Sent.Requests.Reset();

//send a batch of messages
var responses = await _client.SubmitAsync(batch);

//take snapshot of metrics values
var sentRequests = _client.Metrics.Sent.Requests.Snapshot();

// display metrics values as string
string performance = sentRequests.ToString();

Queue State

Note

client.Queue property to be depreciated in v3.0 and greater

Queue propery of type QueueState provides the following parameters:

Property name Description
SendCount A number of PDUs that stay in the send queue before sending to network
ReceiveCount A number of PDUs that stay in the receive queue and wait for being processed with application event handlers.
ReceiveWorkersCount A number of worker threads that process PDUs from receive queue and invoke event handlers in the application
IncompleteRequests A number of request that didn't receive their response