Quantcast
Channel: sharpsnmplib Wiki & Documentation Rss Feed
Viewing all 179 articles
Browse latest View live

Updated Wiki: SharpSnmpPro.Mib Assembly

$
0
0
#SNMP Suite ships with an assembly SharpSnmpLib.Mib which can compile MIB documents and extract some information from them. It only provides limited functionality and users ask for more advanced editions. Here it comes.

The Brand New SharpSnmpPro.Mib Assembly

This assembly is the key component that empowers the Compiler Pro product.
sharpsnmppro.mib.png

Reviewer's Guides

The Reviewer's Guides on Trial and Full editions can be found at,

Supported Platforms

Unlike the Compiler Pro which requires .NET 4.5 and Windows, this assembly can be used on multiple platforms,
  • .NET 4.0 and above (KB4688871 is required)
  • Mono 3.10 and above
  • Xamarin.iOS
  • Xamarin.Android
  • Xamarin.Mac

Purchase

The SharpSnmpPro.Mib assembly can be ordered from Purchase page. For more information, please write to support@lextm.com.

After purchase, you will receive further information on how to activate the product and use it in your development environment.

Licensing Model for SharpSnmpPro.Mib Assembly

When purchasing a license for the SharpSnmpPro.Mib Assembly, you receive a license for one developer and unlimited number of redistributable run-time licenses.

This means that one software developer can install the licensed version of the SharpSnmpPro.Mib Assembly to his or her computer. The redistributable run-time licenses can be deployed in the development environment in order to test and debug the product through its development stages. After the product is fully developed, the redistributable run-time licenses can be deployed (bundled with your application) either within your company (i.e., if you were developing an in-house tool) and/or sold to your end users (again, bundled with your application). You are eligible to redistribute unlimited copies of SharpSnmpPro.Mib Assembly.

Support Contracts

There are several support contracts available.

Maintenance Support

No product is defect free. If you happen to meet a product defect, a support case can be opened and the issue will be investigated and resolved. Such cases are charged at a per-case basis. Maintenance support is primarily email based.

Note that currently purchases of this product come with maintenance support of several months for free as bonus. Try it or buy it!

Advisory Support

The real world scenarios might require customization or consulting, so advisory support cases can be opened. Such cases are charged at a hourly basis. Advisory cases are email or phone based.

Updated Wiki: Home

$
0
0
Produced and supported by LeXtudio.

Project Description

#SNMP Library is a free and open source SNMP class library for developers who target Microsoft .NET/Xamarin Mono platforms. It's developed in C#.

(C) 2008-2015 Malcolm Crowe, Lex Li, and other contributors.

News

Features

Microsoft .NETXamarin MonoOS XOS X, UbuntuUbuntu, and openSUSEopenSUSE.
  • Encapsulate SNMP functions in a natural and easy-to-use API set.
  • Release under MIT/X11. (MIB related portion is released under BSD 3 Clause.)
  • Support .NET Framework 3.5 SP1, 4.0/4.5, .NET Compact Framework 3.5, Mono 2.8+, Xamarin.iOS Unified, and Xamarin.Android.

Support for .NET Framework 2.0 and 3.0 expired on April 12, 2011. #SNMP release BigDipper (7.0) and above no longer supports these two obsolete .NET versions.

Support for .NET Framework 4.0, 4.5, and 4.5.1 will expire on Jan 12, 2016. #SNMP release LordGate (9.0) and above will no longer support there obsolete .NET versions.

Get Started

Please go to Documentation section.

Support services are provided by LeXtudio. Please visit LeXtudio for further information.

Donate

Show your appreciation for this open source project and support future development,

Donate

Pro Editions

#SNMP MIB Compiler Pro and Browser Pro are enterprise specific editions of SNMP utilities that build upon #SNMP Library.

MIB Compiler Pro

Sponsors

In the development process, we received licenses from

VisualSVNPowered by VisualSVN
JetBrains ReSharperPowered by ReSharper
NDependPowered by NDepend

Updated Wiki: 600011

$
0
0

KB 600011 Windows/.NET Framework/Mono support explained

Summary

This article describes for major releases of #SNMP, which version(s) of .NET Framework and Mono are supported.

More Information

Due to limited resources, obsolete #SNMP releases are no longer supported (refer to our roadmap).

By .NET Framework/Mono (the target virtual machine your application runs on)

  • .NET CF 3.5, you can use sharpsnmplib.cf35.dll in TritonMate (8.0). Older CF versions are not supported.
  • .NET 2.0 RTM/.NET 2.0 SP1/.NET 2.0 SP2/.NET 3.0 RTM/.NET 3.0 SP1/.NET 3.0 SP2/.NET 3.5 RTM (without installing .NET 3.5 SP1), you can use SharpSnmpLib.dll in TritonMate (8.0). .NET 1.0 and 1.1 are not supported.
  • .NET 3.5 SP1, you can use all assemblies in TritonMate (8.0)except sharpsnmplib.cf35.dll.

References

Updated Wiki: Roadmap

$
0
0
A natural API interface was done in this release for major SNMP v1 related functions, including GET, GETNEXT, SET, and TRAP.
The code name simply means this release is not feature complete (more than 50 percent of the 1.0 level work was done).
Basic MIB documents support was added in this version to make a feature complete SNMP v1 library.
The code name refers to both Nine-headed Bird (I came from Hubei Province of P.R. China) and Lernaean Hydra.
The 1.0 release was a performance tuned and bug fixed version over 0.9 with few API changes.
The code name contains 1 implicitly, as a unicorn has only one horn.
The 1.1 release is a performance tuned and bug fixed version over 1.0 with a few API changes. This release presents a #SNMP MIB Browser with almost complete v2c coverage.
The code name was initially chosen for 2.0 release and refers to The Two Towers. That's why it does not implicitly contains 1 or 5.
This release completes SNMP v1 and v2c support. IP v6 support is also added.
Now this suite contains SNMP library, a MIB browser, a MIB compiler, and several command line utilities.
The code name means two roads intersect with each other, so it implicitly contains 2 just like TwinTower. Interesting enough that in this release we start to support both IP v4 and v6, which matches the ""two roads" part.
This is a bug fix release that addresses several known issues.
Basic SNMP v3 support is added in 3.0 release.
The code name was chosen by Steve Santacroce (link). Of course, 3 is contained in the name again.
This is a bug fix release that addresses several known issues.
This release delivers an enhanced MIB Browser and Agent.
The code name contains 4, as a square has 4 sides.
This release delivers enhanced SNMP v3 support and achieves official support for Mono/openSUSE.
The code name contains 5 implicitly (a cat's front paw usually has 5 claws, link), but it also refers to Capillary wave.
This is a bug fix release.
This release completes SNMP v3 support and achieves official support for Mono/Ubuntu.
The code name contains 6 implicitly. We host #SNMP on CodePlex, whose icon contains cells with 6 sides.
This is a bug fix release.
This release enhances the compiler and finish migration to .NET 3.5/4.0.
The code name refers to the seven stars
This is a bug fix release. Many 8.0 features are also included (with only a limited set of breaking API).

*TritonMate (8.0) (Obsolete)
This is a bug fix release.
The code name refers to Neptune, as Triton is the bigger moon of Neptune. Note that Neptune is the eighth planet from the Sun in the Solar System.
This is a bug fix release.

Updated Wiki: Roadmap

$
0
0
A natural API interface was done in this release for major SNMP v1 related functions, including GET, GETNEXT, SET, and TRAP.
The code name simply means this release is not feature complete (more than 50 percent of the 1.0 level work was done).
Basic MIB documents support was added in this version to make a feature complete SNMP v1 library.
The code name refers to both Nine-headed Bird (I came from Hubei Province of P.R. China) and Lernaean Hydra.
The 1.0 release was a performance tuned and bug fixed version over 0.9 with few API changes.
The code name contains 1 implicitly, as a unicorn has only one horn.
The 1.1 release is a performance tuned and bug fixed version over 1.0 with a few API changes. This release presents a #SNMP MIB Browser with almost complete v2c coverage.
The code name was initially chosen for 2.0 release and refers to The Two Towers. That's why it does not implicitly contains 1 or 5.
This release completes SNMP v1 and v2c support. IP v6 support is also added.
Now this suite contains SNMP library, a MIB browser, a MIB compiler, and several command line utilities.
The code name means two roads intersect with each other, so it implicitly contains 2 just like TwinTower. Interesting enough that in this release we start to support both IP v4 and v6, which matches the ""two roads" part.
This is a bug fix release that addresses several known issues.
Basic SNMP v3 support is added in 3.0 release.
The code name was chosen by Steve Santacroce (link). Of course, 3 is contained in the name again.
This is a bug fix release that addresses several known issues.
This release delivers an enhanced MIB Browser and Agent.
The code name contains 4, as a square has 4 sides.
This release delivers enhanced SNMP v3 support and achieves official support for Mono/openSUSE.
The code name contains 5 implicitly (a cat's front paw usually has 5 claws, link), but it also refers to Capillary wave.
This is a bug fix release.
This release completes SNMP v3 support and achieves official support for Mono/Ubuntu.
The code name contains 6 implicitly. We host #SNMP on CodePlex, whose icon contains cells with 6 sides.
This is a bug fix release.
This release enhances the compiler and finish migration to .NET 3.5/4.0.
The code name refers to the seven stars
This is a bug fix release. Many 8.0 features are also included (with only a limited set of breaking API).
This is a bug fix release.
The code name refers to Neptune, as Triton is the bigger moon of Neptune. Note that Neptune is the eighth planet from the Sun in the Solar System.
This is a bug fix release.

Updated Wiki: Documentation

$
0
0

Updated Wiki: Samples

$
0
0
The samples can be used to carry out basic SNMP operations. So if you are going to learn the basics, you should follow them.

Pairing the SNMP test agent and the manager side tools

Run snmpd.exe as administrator and click "Start listening" button without modifying any settings. This allows the test SNMP agent to hook to port 161 on all network interfaces (IP v4 and v6).

Information about the agent builtin community names and user accounts can be found in KB600002.

Then the command line utilities can be run at command prompt, where typical commands are documented in KB600001. The agent will respond with correct packets.

Pairing the SNMP test agent and the trap listener tool

Run snmptrapd.exe at command prompt as administrator. It will hook to port 162 and monitor incoming trap messages.

Click the "Sent Trap v1", "Send Trap v2", "Send Inform v2" and "Send Inform v3" buttons on the test agent panel. See those messages are captured by the trap listener tool.

Above setup assumes that all tools are running on the same machine. If you want to test out agent and manager sides each on a dedicate machine, make sure you open the firewall ports and allow SNMP packets to go through.

Updated Wiki: Home

$
0
0
Produced and supported by LeXtudio.

Project Description

#SNMP Library is a free and open source SNMP class library for developers who target Microsoft .NET/Xamarin Mono platforms. It's developed in C#.

(C) 2008-2015 Malcolm Crowe, Lex Li, and other contributors.

News

Features

Microsoft .NETXamarin MonoOS XOS X, UbuntuUbuntu, and openSUSEopenSUSE.
  • Encapsulate SNMP functions in a natural and easy-to-use API set.
  • Release under MIT/X11. (MIB related portion is released under BSD 3 Clause.)
  • Support .NET Framework 3.5 SP1, 4.0/4.5, .NET Compact Framework 3.5, Mono 2.8+, Xamarin.iOS Unified, and Xamarin.Android.

Support for .NET Framework 2.0 and 3.0 expired on April 12, 2011. #SNMP release BigDipper (7.0) and above no longer supports these two obsolete .NET versions.

Support for .NET Framework 4.0, 4.5, and 4.5.1 will expire on Jan 12, 2016. #SNMP release LordGate (9.0) and above will no longer support there obsolete .NET versions.

Get Started

Please go to Documentation section.

Support services are provided by LeXtudio. Please visit LeXtudio for further information.

Donate

Show your appreciation for this open source project and support future development,

Donate

Pro Editions

#SNMP MIB Compiler Pro and Browser Pro are enterprise specific editions of SNMP utilities that build upon #SNMP Library.

MIB Compiler Pro

Sponsors

In the development process, we received licenses from

VisualSVNPowered by VisualSVN
JetBrains ReSharperPowered by ReSharper
NDependPowered by NDepend

Updated Wiki: SNMP v3 Operations

$
0
0
SNMP v1 and v2c were designed to be simple, but one significant issue of them is security. It is very hard to hide community strings from sniffers, and also difficult to set access control on entities.

IETF recognized SNMP v3 RFC documents in 2004, which uses a new design to address the security concerns. The changes were so huge, so #SNMP has to expose a different styles of APIs for developers to perform v3 operations.

Below a few SNMP v3 operations (GET, SET and so on) are translated to #SNMP function calls,

Discovery Process

SNMP v3 defines a discovery process in RFC 3414, that before an SNMP agent responds to a manager the two must interchange information such as time stamp, engine ID and so on.

Discovery discovery = Messenger.GetNextDiscovery(SnmpType.GetRequestPdu);
ReportMessage report = discovery.GetResponse(60000, new IPEndPoint(IPAddress.Parse("192.168.1.2"), 161));

Above we perform such a discovery process by sending out a GetRequestPdu type of discovery message, and the agent replies with a ReportMessage which we can reuse later to construct a valid request.

User Credentials

SNMP v3 requires user credentials to be passed on in each requests, so we need to prepare that information ahead of time.

var auth = new SHA1AuthenticationProvider(new OctetString("myauthenticationpassword"));
var priv = new DESPrivacyProvider(new OctetString("myprivacypassword"), auth);

Assume the agent requires both authentication (SHA-1) and privacy (DES) protection, then above we create a single provider that embeds both passwords.

GET Operation

The following code shows how to send an SNMP v3 GET message to an agent located 192.168.1.2 and query on OID 1.3.6.1.2.1.1.1.0,

GetRequestMessage request = new GetRequestMessage(VersionCode.V3, Messenger.NextMessageId, Messenger.NextRequestId, new OctetString("myname"), new List<variable>{new Variable(new ObjectIdentifier("1.3.6.1.2.1.1.1.0"))}, priv, Messenger.MaxMessageSize, report);
ISnmpMessage reply = request.GetResponse(60000, new IPEndPoint(IPAddress.Parse("192.168.1.2"), 161));
if (reply.Pdu().ErrorStatus.ToInt32() != 0) // != ErrorCode.NoError
{
    throw ErrorException.Create(
        "error in response",
        IPAddress.Parse("192.168.1.2"),
        reply);
}

The reply object usually contains the response message we expect. By accessing reply.Pdu().Variables we can see what data are returned.

SET Operation

The following code shows how to send an SNMP v3 SET message to an SNMP agent located at 192.168.1.2 and set the value of OID 1.3.6.1.2.1.1.6.0 to "Shanghai",

SetRequestMessage request = new GetRequestMessage(VersionCode.V3, Messenger.NextMessageId, Messenger.NextRequestId, new OctetString("myname"), new List<variable>{new Variable(new ObjectIdentifier("1.3.6.1.2.1.1.1.0"), new OctetString("Shanghai"))}, priv, Messenger.MaxMessageSize, report);
ISnmpMessage reply = request.GetResponse(60000, new IPEndPoint(IPAddress.Parse("192.168.1.2"), 161));
if (reply.Pdu().ErrorStatus.ToInt32() != 0) // != ErrorCode.NoError
{
    throw ErrorException.Create(
        "error in response",
        IPAddress.Parse("192.168.1.2"),
        reply);
}

GET-BULK Operation

The following code shows how to send an SNMP v3 GET-BULK message to an SNMP agent located at 192.168.1.2 and query on OID 1.3.6.1.2.1.1.1.0,

GetBulkRequestMessage request = new GetBulkRequestMessage(VersionCode.V3, Messenger.NextMessageId, Messenger.NextRequestId, new OctetString("myname"), 0, 10, new List<variable>{new Variable(new ObjectIdentifier("1.3.6.1.2.1.1.1.0"))}, priv, Messenger.MaxMessageSize, report);
ISnmpMessage reply = request.GetResponse(60000, new IPEndPoint(IPAddress.Parse("192.168.1.2"), 161));
if (reply.Pdu().ErrorStatus.ToInt32() != 0) // != ErrorCode.NoError
{
    throw ErrorException.Create(
        "error in response",
        IPAddress.Parse("192.168.1.2"),
        reply);
}

var result = reply.Pdu().Variables;

WALK Operation

The following code shows how to perform v3 WALK on an SNMP agent located at 192.168.1.2 starting at 1.3.6.1.2.1.1,

var result = new List<variable>();
Messenger.BulkWalk(VersionCode.V3, 
                   new IPEndPoint(IPAddress.Parse("192.168.1.2"), 161), 
                   new OctetString("public"), 
                   new ObjectIdentifier("1.3.6.1.2.1.1"), 
                   result, 
                   60000, 
                   10, 
                   WalkMode.WithinSubtree, 
                   priv, 
                   report);

TRAP v2 Operation

Note that TRAP v1 message format is obsolete by TRAP v2. Thus, for SNMP v3 TRAP operations, you can only use TRAP v2 message format.

The following code shows how to send a TRAP v2 message to an SNMP manager/trap listener located at 192.168.1.2,

var trap = new TrapV2Message(
                VersionCode.V3,
                528732060,
                1905687779,
                new OctetString("neither"),
                new ObjectIdentifier("1.3.6"),
                0,
                new List<Variable>(),
                DefaultPrivacyProvider.DefaultPair,
                0x10000,
                new OctetString(ByteTool.Convert("80001F8880E9630000D61FF449")),
                0,
                0
               );
trap.Send(new IPEndPoint(IPAddress.Parse("192.168.1.2"), 162));

INFORM Operation

Comparing to sending TRAP v2 messages, it is common to send INFORM messages.

The following code shows how to send an INFORM message to an SNMP manager/trap listener located at 192.168.1.2,

Messenger.SendInform(
                    0,
                    VersionCode.V3,
                    new IPEndPoint(IPAddress.Parse("192.168.1.2"), 162),
                    new OctetString("neither"),
                    new ObjectIdentifier(new uint[] { 1, 3, 6 }),
                    0,
                    new List<Variable>(),
                    2000,
                    DefaultPrivacyProvider.DefaultPair,
                    report);


To help you understand how to use the API provided by #SNMP Library, there are more sample projects you can find under Samples folder in source code package. Both C# and VB.NET samples are available.

The help documentation is available online at http://help.sharpsnmp.com.

Updated Wiki: 600005

$
0
0

KB 600005 How to compile source code on Windows

Summary

This article describes how to compile #SNMP source code on Windows.

Prerequisites

You may download the source code from https://github.com/lextm/sharpsnmplib/releases.

Default Configuration

#SNMP has several projects.

For release 8.0 and below, most of them are configured to compile against .NET Framework 3.5 except SharpSnmpLib.csproj who is against .NET Framework 2.0.

If you have .NET Framework 3.5 installed

.NET Framework 3.5 SP1 is available here.
  1. Install .NET SDK or Visual Studio.
  2. Execute prepare.bat to prepare necessary files.
  3. Execute release.35.bat to build the source code.
The compiled binaries are in the bin folder. They are built using MSBuild 3.5. Core assemblies are against .NET 2.0 SP2, while others against .NET 3.5 SP1.

For release 8.5, the projects are configured to compile against .NET 4.0.

If you have .NET Framework 4.0 installed

.NET Framework 4.0 installer is available here.
  1. Install .NET SDK or Visual Studio.
  2. Execute prepare.bat to prepare necessary files.
  3. Execute release.bat to build the source code.
The compiled binaries are in the bin folder. They are built using MSBuild 4.0.

.NET 4

Visual Studio 2013 Community Edition is the recommended IDE to view and edit the code base.

More Information

#SNMP is supported on Windows Vista (SP2), Windows 7 (SP1), Windows Server 2008 (SP2), Windows Server 2008 R2, Windows 8, Windows Server 2012, Windows 8.1, Windows Server 2012 R2 and Windows 10.

Windows XP and Windows Server 2003 support have expired due to Microsoft product lifecycle.

References

N/A

Updated Wiki: Documentation

$
0
0

Updated Wiki: CompilerProReview

$
0
0
The Trial Edition can be requested here, and is packaged up with #SNMP Library 8.5 and the latest SharpSnmpPro.Mib.

To test it out, the default test MIB documents can be found at GitHub. It can be cloned to a local folder, such as D:\sharpsnmppro-mib.
git clone https://github.com/lextm/sharpsnmppro-mib.git

Then the documents can be copied to that folder (D:\sharpsnmppro-mib for example).

Launch the compiler by executing Compiler.exe and then click File | Open menu item to navigate to D:\sharpsnmppro-mib folder in Open file dialog.

Change the file extension filter to All files (.), and then select all .txt files in this folder. Click Open button to open all files in the compiler. The file names should appear in Solution Explorer panel.

Click Build | Compile menu item to start compiling the files. In a few seconds, the Object Tree panel should be updated with objects extracted from the files, while Module List panel shows the loaded modules (as well as pending ones). The Error List panel should display any error or warnings. The Output panel contains the diagnostics logging entries.

Updated Wiki: FAQ

$
0
0
How can I learn more about SNMP and MIB?
Answer: For beginners you might start from good books such as Essential SNMP and Understanding SNMP MIBs.

For advanced, you might check out the original RFC documents from IETF and review existing SNMP implementation such as Net-SNMP.

Where can I find more samples?
Answer: The source code package contains more samples, which are under Samples folder. Both C# and VB.NET samples are available.

Why are there only C#/VB.NET samples?
Answer: You can easily convert C# sample code to other .NET languages using this SharpDevelop web site. The conversion result may not be perfect, but it shows how to make API calls.

ILSpy is another tool that can help translate the code. Simply open our C# version samples (exe or dll) and check the disassembled code.

The good news is that VB.NET samples are added in 5.0 release.

Is there a class reference?
Answer: Help packages (both CHM and Help2 versions) are available in binary release packages. You can also build them from source code.

What if my question is not answered in the KB articles?
Answer: You can check the StackOverflow, as project team already answered a lot of questions there. If your question is not listed there, please post it and wait for replies.

Is this library free for commercial projects?
Answer: It is really hard to start an open source project because you need to find a proper license. In my case, I want this library to be both strict open source and friendly to commercial world. Therefore, at last I use MIT/X11 to cover the code. This means if you follow MIT/X11 rules, you can use this library in commercial projects for free. Note that portion of the code base is covered by BSD 3 Clause.

Does it support SNMP v3?
Answer: SNMP v3 support is complete. #SNMP supports all RFC required authentication (MD5, SHA-1) and privacy (DES, AES) algorithms.

Does it support all SNMP devices?
Answer: Probably not. SNMP has been an ancient protocol, but not all vendor products (both hardware and software) strictly follow the rules. #SNMP is only capable of supporting most of them which are standard compliant.

Non standard devices can lead to various issues, and below are the ones reported back by users,

It is not a complete list but should shed some light on how to troubleshoot and locate the culprit. You will have to modify #SNMP to adapt to those problems on your own.

What's the current version and previous versions?
Answer: Please refer to our Roadmap here.

Why should I use this library?
Answer: It is hard to explain.
On one hand, there are indeed a lot of commercial packages available throughout the market. However, my evaluation shows that most of them are too expensive and a few of them only provides limited functions a developer may need.
On the other hand, there are few open source packages existing on .NET platform. For example, I cannot compile SNMP++.NET successfully and I don't think that library provides a natural enough API interface.

Could I contribute to this project?
Answer: Welcome. You can do a lot to help even if you may not have the chance and ability to contribute patches and new functions.
Here are a list of items I expect,
  • Comments on the API, such as "this part of API is not natural enough. We need to change it to blah blah blah and then it is more natural".
  • Bug reports, such as "it does not work in my case. What's up then"?
  • Patches, such as "I found a bug and created a patch to fix it, so please merge it into the repository". I am more than glad to hear from you.
  • New functions, such as "why not implement something like this".
You can always start your own fork from here

Why choosing CodePlex as homepage and GitHub as source code host?
Answer: Well, I think combination of the two matches all needs of this project.

Why when I compile the source code weird errors happen?
Answer: You will need to use Git to check out the source code. I don't support ZIP packages downloaded from CodePlex.

Which language does this library support?
Answer: Technically speaking, all .NET languages are supported, such as C#, VB.NET, Oxygene, C++/CLI, IronPython, IronRuby, and so on.

Is this library thread safe?
Answer: Not yet. Please use static methods in Messenger class which should be thread safe.

How to diagnose problems?
Answer: Please follow KB 600008.

Why are some methods marked as Obsolete?
Answer: #SNMP Library API changes across major releases. Therefore, there are some methods marked as obsolete somewhere. Please avoid using them as they are to be removed in future releases.

How to fire feature requests?
Answer: You can add new feature requests and vote on features using the Issue Tracker.

If all above do not resolve your problem or you have questions on them, please feel free to start a discussion in StackOverflow.

Updated Wiki: Home

$
0
0
Produced and supported by LeXtudio.

Project Description

#SNMP Library is a free and open source SNMP class library for developers who target Microsoft .NET/Xamarin Mono platforms. It's developed in C#.

(C) 2008-2016 Malcolm Crowe, Lex Li, and other contributors.

News

Features

Microsoft .NETXamarin MonoOS XOS X, UbuntuUbuntu, and openSUSEopenSUSE.
  • Encapsulate SNMP functions in a natural and easy-to-use API set.
  • Release under MIT/X11. (MIB related portion is released under BSD 3 Clause.)
  • Support .NET Framework 3.5 SP1, 4.5.2, Mono 4.2, Xamarin.iOS Unified, and Xamarin.Android.

Support for .NET Framework 2.0 and 3.0 expired on April 12, 2011. #SNMP release BigDipper (7.0) and above no longer supports these two obsolete .NET versions.

Support for .NET Framework 4.0, 4.5, and 4.5.1 expired on Jan 12, 2016. #SNMP release LordGate (9.0) and above will no longer support there obsolete .NET versions.

Get Started

Please go to Documentation section.

Support services are provided by LeXtudio. Please visit LeXtudio for further information.

Donate

Show your appreciation for this open source project and support future development,

Donate

Pro Editions

#SNMP MIB Compiler Pro and Browser Pro are enterprise specific editions of SNMP utilities that build upon #SNMP Library.

MIB Compiler Pro

Sponsors

In the development process, we received licenses from

VisualSVNPowered by VisualSVN
JetBrains ReSharperPowered by ReSharper
NDependPowered by NDepend

Updated Wiki: Documentation

$
0
0

Updated Wiki: License Notice

$
0
0
Documentation has moved to the new site. This page won't be updated any more.

For detailed information on source code licensing, please read KB 600012.

Updated Wiki: Export Restrictions

$
0
0
Documentation has moved to the new site. This page won't be updated any more.

The #SNMP Library is open source software that contains strong encryption. Specifically, it has the ability to encrypt and decrypt SNMPv3 protocol. Its primary distribution point is in the United States, and subsequently falls under U.S. encryption export regulations.

To the best of our knowledge, #SNMP Library falls under ECCN 5D002 and qualifies for license exemption TSU under Section 734.3(b)(3) of the EAR. There are no U.S. regulations that prohibit you from downloading #SNMP Library.

Frank Hecker has written a detailed explanation of Mozilla's ECCN. It applies to other open source software, including #SNMP Library.

Addendum: Prior to January 7, 2011, downloading #SNMP Library in Cuba, Iran, North Korea, Libya, Sudan, and Syria was prohibited. On January 7, 2011 the U.S. Bureau of Industry and Security removed this restriction.

The information above follows Wireshark's claim. Consult a lawyer if you have any questions.

Updated Wiki: An introduction

$
0
0
Documentation has moved to the new site. This page won't be updated any more.

Below a few SNMP operations (GET, SET and so on) are translated to #SNMP function calls,

GET Operation

The following code shows how to send an SNMP v1 GET message to an SNMP agent located at 192.168.1.2 and query on OID 1.3.6.1.2.1.1.1.0,

var result = Messenger.Get(VersionCode.V1, 
                           new IPEndPoint(IPAddress.Parse("192.168.1.2"), 161), 
                           new OctetString("public"),
                           new List<Variable>{new Variable(new ObjectIdentifier("1.3.6.1.2.1.1.1.0"))},
                           60000);

This operation will time out if no reply is received after 60 seconds (1 minute), and throw an exception (TimeoutException). If any error occurs, an ErrorException can be caught. All #SNMP exceptions are derived from SnmpException.

The result returned is a list that matches the list of Variable objects sent. The Variable in this list contains the value of the OID.

SET Operation

The following code shows how to send an SNMP v1 SET message to an SNMP agent located at 192.168.1.2 and set the value of OID 1.3.6.1.2.1.1.6.0 to "Shanghai",

var result = Messenger.Set(VersionCode.V1, 
                           new IPEndPoint(IPAddress.Parse("192.168.1.2"), 161), 
                           new OctetString("public"),
                           new List<Variable>{new Variable(new ObjectIdentifier("1.3.6.1.2.1.1.6.0"), new OctetString("Shanghai"))},
                           60000);

GET-NEXT Operation

The following code shows how to send an SNMP v1 GET-NEXT message to an SNMP agent located at 192.168.1.2 and query on OID 1.3.6.1.2.1.1.1.0,

GetNextRequestMessage message = new GetNextRequestMessage(0,
                              VersionCode.V1,
                              new OctetString("public"),
                              new List<Variable>{new Variable(new ObjectIdentifier("1.3.6.1.2.1.1.6.0"))});
ISnmpMessage response = message.GetResponse(60000, new IPEndPoint(IPAddress.Parse("192.168.1.2"), 161));
if (response.Pdu().ErrorStatus.ToInt32() != 0) 
{
    throw ErrorException.Create(
        "error in response",
        receiver.Address,
        response);
}

var result = response.Pdu().Variables;

GET-BULK Operation

The following code shows how to send an SNMP v2 GET-BULK message to an SNMP agent located at 192.168.1.2 and query on OID 1.3.6.1.2.1.1.1.0,

GetBulkRequestMessage message = new GetBulkRequestMessage(0,
                      VersionCode.V2,
                      new OctetString("public"),
                      0,
                      10,
                      new List<Variable>{new Variable(new ObjectIdentifier("1.3.6.1.2.1.1.6.0"))});
ISnmpMessage response = message.GetResponse(60000, new IPEndPoint(IPAddress.Parse("192.168.1.2"), 161));
if (response.Pdu().ErrorStatus.ToInt32() != 0)
{
    throw ErrorException.Create(
        "error in response",
        receiver.Address,
        response);
}

var result = response.Pdu().Variables;

Walk Operation

Walk is not an atomic operation. That means, it utilizes several GET-NEXT (SNMP v1 walk) or GET-BULK (v2 and above). The following code shows how to perform walk on an SNMP agent located at 192.168.1.2 starting at 1.3.6.1.2.1.1,

var result = new List<Variable>();
Messenger.Walk(VersionCode.V1, 
               new IPEndPoint(IPAddress.Parse("192.168.1.2"), 161), 
               new OctetString("public"), 
               new ObjectIdentifier("1.3.6.1.2.1.1"), 
               result, 
               60000, 
               WalkMode.WithinSubtree);

The result returned contains a list of all available OIDs (as Variable) in this SNMP agent that under tree node of 1.3.6.1.2.1.1.

#SNMP supports two walk modes, Default and WithinSubtree.

Messenger.Walk is built GET-NEXT. Note that Messenger.BulkWalk should be used if the device supports SNMP v2, as it is built on GET-BULK and provide better performance.

var result = new List<Variable>();
Messenger.BulkWalk(VersionCode.V2, 
                   new IPEndPoint(IPAddress.Parse("192.168.1.2"), 161), 
                   new OctetString("public"), 
                   new ObjectIdentifier("1.3.6.1.2.1.1"), 
                   result, 
                   60000, 
                   10, 
                   WalkMode.WithinSubtree, 
                   null, 
                   null);

TRAP Operation

It is usually an SNMP agent that sends out TRAP messages. The following code shows how to send an empty SNMP v1 TRAP message from 192.168.1.2 to an SNMP manager located at 192.168.1.3,

Messenger.SendTrapV1(new IPEndPoint(IPAddress.Parse("192.168.1.3"), 162), 
                     IPAddress.Parse("192.168.1.2"), 
                     new OctetString("public"), 
                     new ObjectIdentifier("1.3.6.1.2.1.1"), 
                     GenericCode.ColdStart, 
                     0, 
                     0, 
                     new List<Variable>();

SNMP v2 and above introduces a simplified TRAP v2 message,

Messenger.SendTrapV2(0, 
                     VersionCode.V2, 
                     new IPEndPoint(IPAddress.Parse("192.168.1.3"), 162), 
                     new OctetString("public"), 
                     new ObjectIdentifier("1.3.6.1.2.1.1"), 
                     0, 
                     new List<Variable>());

INFORM Operation

It is usually an SNMP agent that sends out INFORM messages. The following code shows how to send an empty INFORM message to an SNMP manager located at 192.168.1.3,

Messenger.SendInform(0, 
                     VersionCode.V2, 
                     new IPEndPoint(IPAddress.Parse("192.168.1.3"), 162), 
                     new OctetString("public"), 
                     new ObjectIdentifier("1.3.6.1.2.1.1"), 
                     0, 
                     new List<Variable>(), 
                     2000, 
                     null, 
                     null);

The manager should send back a reply to this INFORM message. Otherwise, a TimeoutException occurs.

To help you understand how to use the API provided by #SNMP Library, there are more sample projects you can find under Samples folder in source code package. Both C# and VB.NET samples are available.

Updated Wiki: SNMP v3 Operations

$
0
0
Documentation has moved to the new site. This page won't be updated any more.

SNMP v1 and v2c were designed to be simple, but one significant issue of them is security. It is very hard to hide community strings from sniffers, and also difficult to set access control on entities.

IETF recognized SNMP v3 RFC documents in 2004, which uses a new design to address the security concerns. The changes were so huge, so #SNMP has to expose a different styles of APIs for developers to perform v3 operations.

Below a few SNMP v3 operations (GET, SET and so on) are translated to #SNMP function calls,

Discovery Process

SNMP v3 defines a discovery process in RFC 3414, that before an SNMP agent responds to a manager the two must interchange information such as time stamp, engine ID and so on.

Discovery discovery = Messenger.GetNextDiscovery(SnmpType.GetRequestPdu);
ReportMessage report = discovery.GetResponse(60000, new IPEndPoint(IPAddress.Parse("192.168.1.2"), 161));

Above we perform such a discovery process by sending out a GetRequestPdu type of discovery message, and the agent replies with a ReportMessage which we can reuse later to construct a valid request.

User Credentials

SNMP v3 requires user credentials to be passed on in each requests, so we need to prepare that information ahead of time.

var auth = new SHA1AuthenticationProvider(new OctetString("myauthenticationpassword"));
var priv = new DESPrivacyProvider(new OctetString("myprivacypassword"), auth);

Assume the agent requires both authentication (SHA-1) and privacy (DES) protection, then above we create a single provider that embeds both passwords.

GET Operation

The following code shows how to send an SNMP v3 GET message to an agent located 192.168.1.2 and query on OID 1.3.6.1.2.1.1.1.0,

GetRequestMessage request = new GetRequestMessage(VersionCode.V3, Messenger.NextMessageId, Messenger.NextRequestId, new OctetString("myname"), new List<variable>{new Variable(new ObjectIdentifier("1.3.6.1.2.1.1.1.0"))}, priv, Messenger.MaxMessageSize, report);
ISnmpMessage reply = request.GetResponse(60000, new IPEndPoint(IPAddress.Parse("192.168.1.2"), 161));
if (reply.Pdu().ErrorStatus.ToInt32() != 0) // != ErrorCode.NoError
{
    throw ErrorException.Create(
        "error in response",
        IPAddress.Parse("192.168.1.2"),
        reply);
}

The reply object usually contains the response message we expect. By accessing reply.Pdu().Variables we can see what data are returned.

SET Operation

The following code shows how to send an SNMP v3 SET message to an SNMP agent located at 192.168.1.2 and set the value of OID 1.3.6.1.2.1.1.6.0 to "Shanghai",

SetRequestMessage request = new GetRequestMessage(VersionCode.V3, Messenger.NextMessageId, Messenger.NextRequestId, new OctetString("myname"), new List<variable>{new Variable(new ObjectIdentifier("1.3.6.1.2.1.1.1.0"), new OctetString("Shanghai"))}, priv, Messenger.MaxMessageSize, report);
ISnmpMessage reply = request.GetResponse(60000, new IPEndPoint(IPAddress.Parse("192.168.1.2"), 161));
if (reply.Pdu().ErrorStatus.ToInt32() != 0) // != ErrorCode.NoError
{
    throw ErrorException.Create(
        "error in response",
        IPAddress.Parse("192.168.1.2"),
        reply);
}

GET-BULK Operation

The following code shows how to send an SNMP v3 GET-BULK message to an SNMP agent located at 192.168.1.2 and query on OID 1.3.6.1.2.1.1.1.0,

GetBulkRequestMessage request = new GetBulkRequestMessage(VersionCode.V3, Messenger.NextMessageId, Messenger.NextRequestId, new OctetString("myname"), 0, 10, new List<variable>{new Variable(new ObjectIdentifier("1.3.6.1.2.1.1.1.0"))}, priv, Messenger.MaxMessageSize, report);
ISnmpMessage reply = request.GetResponse(60000, new IPEndPoint(IPAddress.Parse("192.168.1.2"), 161));
if (reply.Pdu().ErrorStatus.ToInt32() != 0) // != ErrorCode.NoError
{
    throw ErrorException.Create(
        "error in response",
        IPAddress.Parse("192.168.1.2"),
        reply);
}

var result = reply.Pdu().Variables;

WALK Operation

The following code shows how to perform v3 WALK on an SNMP agent located at 192.168.1.2 starting at 1.3.6.1.2.1.1,

var result = new List<variable>();
Messenger.BulkWalk(VersionCode.V3, 
                   new IPEndPoint(IPAddress.Parse("192.168.1.2"), 161), 
                   new OctetString("public"), 
                   new ObjectIdentifier("1.3.6.1.2.1.1"), 
                   result, 
                   60000, 
                   10, 
                   WalkMode.WithinSubtree, 
                   priv, 
                   report);

TRAP v2 Operation

Note that TRAP v1 message format is obsolete by TRAP v2. Thus, for SNMP v3 TRAP operations, you can only use TRAP v2 message format.

The following code shows how to send a TRAP v2 message to an SNMP manager/trap listener located at 192.168.1.2,

var trap = new TrapV2Message(
                VersionCode.V3,
                528732060,
                1905687779,
                new OctetString("neither"),
                new ObjectIdentifier("1.3.6"),
                0,
                new List<Variable>(),
                DefaultPrivacyProvider.DefaultPair,
                0x10000,
                new OctetString(ByteTool.Convert("80001F8880E9630000D61FF449")),
                0,
                0
               );
trap.Send(new IPEndPoint(IPAddress.Parse("192.168.1.2"), 162));

INFORM Operation

Comparing to sending TRAP v2 messages, it is common to send INFORM messages.

The following code shows how to send an INFORM message to an SNMP manager/trap listener located at 192.168.1.2,

Messenger.SendInform(
                    0,
                    VersionCode.V3,
                    new IPEndPoint(IPAddress.Parse("192.168.1.2"), 162),
                    new OctetString("neither"),
                    new ObjectIdentifier(new uint[] { 1, 3, 6 }),
                    0,
                    new List<Variable>(),
                    2000,
                    DefaultPrivacyProvider.DefaultPair,
                    report);


To help you understand how to use the API provided by #SNMP Library, there are more sample projects you can find under Samples folder in source code package. Both C# and VB.NET samples are available.

The help documentation is available online at http://help.sharpsnmp.com.

Updated Wiki: Agent Development

$
0
0
Documentation has moved to the new site. This page won't be updated any more.

When you open snmpd.csproj in Visual Studio (or another IDE), you should first check what are its references.

Dependencies

There are several references you should pay attention to,
  • SharpSnmpLib.Portable.dll and SharpSnmpLib.Full.dll are our #SNMP Library components.

Note that you might use iOS or Android specific files if targeting those platforms.

Facade, and Pipeline

We no longer need to construct an Agent object, because that class is too old to be used. We try to construct an SnmpEngine instead.

SnmpEngine is the facade that you should put on top. It is a very complex class that replaces our old Agent class. To construct it, we need: an EngineGroup object, which contains all engine global objects; A Listener object, which monitors incoming SNMP message; An SnmpApplicationFactory, who manages the pipelines.

SnmpApplicationFactory creates new pipelines when its pipeline pool is full of busy pipelines. The objects we pass to its constructor finally goes into each pipeline as they are shared among them (at this moment).

A pipeline is in fact an SnmpApplication object. It has several processing phases and each phase utilizes a few helper classes, which you can extend.

An SNMP message captured by Listener will be packaged as an SnmpContext object. This context object is passed to the pipeline and processed in each phase to generate a correct response message.

About how to construct instances of each classes, you can refer to snmpd sample.

Pipeline in Details

Currently we only have four phases in the pipeline,
  1. Authentication
  2. Request handler mapping
  3. Request handler executing
  4. Logging request

Authentication

By checking the sample code you can see how the primary membership provider (ComposedMembershipProvider) is created and added into the pipeline. The request is checked by the provider and dropped if it does not contain a proper community name.

ComposedMembershipProvider is a special membership provider, who allows you to support different SNMP versions. If you only target a specific version, you can use the version specific provider as primary one.

To customize authentication, make use of the existing providers or write your own.

Request handler mapping

For authenticated message, in this phase it is verified again and mapped to a message handler.

Message handlers are injected to the pipeline, too. So you can analyze app.config to know how many handlers are there already, and how each registers its interested message (SNMP version and verb).

For example, GetV1MessageHandler is only interested in v1 GET messages, while GetMessageHandler in v2 and v3 GET messages.

Carefully configure the existing handlers, you can achieve different SNMP engine configurations, so as to meet different requirements. You can write your own handlers to further customize the pipeline.

Request handler executing

Once a message handler is found for the message, in this phase the handler performs the requested operation and generate a response message.

You should notice that *V1MessageHandler classes follow RFC 1157 specification to handle v1 messages, while other handler classes follow RFC 3416 to handle v2 and v3 messages.

Logging request

In this phase the response message is sent back, while the logger logs the processing into log files.

After phase 4, the pipeline is reused by SnmpApplicationFactory for future messages.

We may add an authorization phase to achieve user based authorization, but it is not yet designed and implemented.

ObjectStore and ISnmpObject

When a handler tries to do a typical SNMP operation, it looks into the ObjectStore object to locate the specified object.

Currently we only have a few sample objects created, to test out the pipeline. You can find them under Lextm.SharpSnmpLib.Objects namespace.

If you want to write more objects, you can follow our sample ones.

ObjectStore is not yet thread safe, which will be improved in the future.

Performance Tuning

The SNMP engine is multi-threading by nature. Both the ListenerBinding and SnmpApplication instances utilize the default thread pool to handle requests asynchronously. Thus, it is a must to make sure the thread pool is optimized before requests come in.

Before calling SnmpEngine.Start, it is recommended that the below code to be executed, which sets the minimal worker thread count to a suitable value.
int minWorker, minIOC;
// Get the current settings.
ThreadPool.GetMinThreads(out minWorker, out minIOC);
var threads = engine.Listener.Bindings.Count;
ThreadPool.SetMinThreads(threads + 1, minIOC);

If not tuned, the very first request to this agent will cost extra time (noticeably several seconds if there are too many bindings), as the operating system needs to create new threads before putting them into the thread pool.

The Last Words

You should take a look at MainForm.cs and read what extra lines are required to configure the SnmpEngine object, how to start and stop it.

As the sample is released under MIT license, you can feel free to use it as a starting point of your own SNMP agent.

Our browser sample also uses the pipeline to handle trap messages, and once you are familiar with snmpd, you can switch to it to learn how to construct a browser side pipeline accordingly.

The pipeline greatly enhances our message processing infrastructure, and you should spare some time to go through its current status.

A lot of improvements will be provided in the future to further enhance this useful design.
Viewing all 179 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>