Skyline.DataMiner.Utils.Rates.Protocol 1.0.0.6

Prefix Reserved
dotnet add package Skyline.DataMiner.Utils.Rates.Protocol --version 1.0.0.6
                    
NuGet\Install-Package Skyline.DataMiner.Utils.Rates.Protocol -Version 1.0.0.6
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Skyline.DataMiner.Utils.Rates.Protocol" Version="1.0.0.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Skyline.DataMiner.Utils.Rates.Protocol" Version="1.0.0.6" />
                    
Directory.Packages.props
<PackageReference Include="Skyline.DataMiner.Utils.Rates.Protocol" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Skyline.DataMiner.Utils.Rates.Protocol --version 1.0.0.6
                    
#r "nuget: Skyline.DataMiner.Utils.Rates.Protocol, 1.0.0.6"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Skyline.DataMiner.Utils.Rates.Protocol@1.0.0.6
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Skyline.DataMiner.Utils.Rates.Protocol&version=1.0.0.6
                    
Install as a Cake Addin
#tool nuget:?package=Skyline.DataMiner.Utils.Rates.Protocol&version=1.0.0.6
                    
Install as a Cake Tool

Skyline.DataMiner.Utils.Rates.Protocol

About

Skyline.DataMiner.Utils.Rates are several packages available in the public nuget store that contain assemblies that assist in the calculation of rates (e.g. bitrates).

These allow the developer to accurately calculate rates from counters commonly provided by devices or services.

Documentation: Rate Calculations

The following packages are available that concern rate calculations:

  • Skyline.DataMiner.Utils.Interfaces
  • Skyline.DataMiner.Utils.Rates.Protocol
  • Skyline.DataMiner.Utils.Rates.Common

Requirements

The "DataMiner Integration Studio" Visual Studio extension is required for development of connectors and Automation scripts using NuGets.

See Installing DataMiner Integration Studio

NuGets are mandatory to be installed with PackageReferences. DIS was redesigned to work with PackageReferences and be future-proof.

For more information on how to migrate from packages.config to PackageReferences, see docs.microsoft.com.

Getting started

Beginning from counters received from SNMP through the Protocol XML:

        // Build SNMP Delta Helper
        SnmpDeltaHelper snmpDeltaHelper = new SnmpDeltaHelper(protocol, GroupId);

        // Get buffered data and make a helper instance from it
        string bufferedData = Convert.ToString(protocol.GetParameter(Parameter.counterratedata));
        SnmpRate32 snmpRateHelper = SnmpRate32.FromJsonString(bufferedData, minDelta, maxDelta);

        // Calculate rate
        uint counter = GetNewCounterFromSnmpParam(protocol);
        double rate = snmpRateHelper.Calculate(snmpDeltaHelper, counter);

        // Save results and buffered data
        Dictionary<int, object> paramsToSet = new Dictionary<int, object>
        {
            { Parameter.counter, counter },
            { Parameter.counterrate, rate },
            { Parameter.counterratedata, snmpRateHelper.ToJsonString() },
        };

        protocol.SetParameters(paramsToSet.Keys.ToArray(), paramsToSet.Values.ToArray());

Beginning from counters received through other means:

        // Get buffered data and make a helper instance from it
        string bufferedData = Convert.ToString(protocol.GetParameter(Parameter.counterrateondatesdata)); 
        Rate32OnDateTime rate32OnDatesHelper = Rate32OnDateTime.FromJsonString(bufferedData, minDelta, maxDelta); 

        // Calculate rate
        uint counter = GetNewCounterFromDataSource(protocol);
        double rate = rate32OnDatesHelper.Calculate(counter, DateTime.Now);

        // Save results and buffered data
        Dictionary<int, object> paramsToSet = new Dictionary<int, object>
        {
            { Parameter.counter, counter },
            { Parameter.counterrateondates, rate },
            { Parameter.counterrateondatesdata, rate32OnDatesHelper.ToJsonString() },
        };

        protocol.SetParameters(paramsToSet.Keys.ToArray(), paramsToSet.Values.ToArray());

Negative rates

A negative rate is not necessarily wrong: for some counters a decreasing value is perfectly legitimate. For others it is unexpected and undesired, for example because the device reset the counter or because of a device bug. By default, negative rates are returned as calculated.

Whether to use the optional overrideNegativeRatesWith argument depends on the use case: on whether a negative rate is legitimate for the counter at hand, and on whether a counter reset can be detected by other means. If an unexpected and undesired negative rate must not be returned, pass it to FromJsonString:

        // Returns -1 (instead of the negative rate) when an unexpected and undesired negative rate is calculated
        SnmpRate32 snmpRateHelper = SnmpRate32.FromJsonString(bufferedData, minDelta, maxDelta, RateBase.Second, overrideNegativeRatesWith: -1);

Choose an exceptional value (or protocol.Leave in a protocol) rather than 0, as 0 is a proper rate value.

When a negative rate is detected, the buffered counters are discarded, the new counter becomes the first buffered counter and the given value is returned. The default (null) keeps returning negative rates. Counter wrap-arounds are still handled as before and never result in a negative rate. The option is not serialized, so it must be provided each time FromJsonString is called.

Product Compatible and additional computed target framework versions.
.NET Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0.6 180 11/17/2026
1.0.0.5 24,387 5/7/2024
1.0.0.4 5,563 11/28/2023
1.0.0.3 3,005 9/4/2023
1.0.0.2 1,932 6/26/2023
1.0.0.1 2,770 1/26/2023