SNMP Protocol Data Unit

Namespace: SnmpSharpNet
Assembly: SnmpSharpNet (in SnmpSharpNet.dll) Version: 0.9.1.0 (0.9.1)

Syntax

C#
public class Pdu : AsnType, ICloneable, IEnumerable<Vb>, 
	IEnumerable
Visual Basic
Public Class Pdu _
	Inherits AsnType _
	Implements ICloneable, IEnumerable(Of Vb),  _
	IEnumerable
Visual C++
public ref class Pdu : public AsnType, 
	ICloneable, IEnumerable<Vb^>, IEnumerable

Remarks

SNMP PDU class that is the bases for all SNMP requests and replies. It is capable of processing SNMPv1 GET, GET-NEXT, REPLY and SNMPv2 GET, GET-NEXT, GET-BULK, REPLY, V2TRAP, INFORM and REPORT PDUs.
CopyC#
Pdu pdu = new Pdu();
pdu.Type = PduType.Get;
pdu.VbList.AddVb("1.3.6.1.2.1.1.1.0");
pdu.VbList.AddVb("1.3.6.1.2.1.1.2.0");
By default, Pdu class initializes the RequestId (unique identifier of each SNMP request made by the manager) with a random value. User can force a new, random request id generation at the time packet is encoding by changing RequestId to 0. If you wish to set a specific RequestId, you can do it this way:
CopyC#
Pdu pdu = new Pdu();
pdu.Type = PduType.GetNext;
pdu.RequestId = 11; // Set a custom request id
pdu.VbList.AddVb("1.3.6.1.2.1.1");
Pdu types with special options are notification PDUs, V2TRAP and INFORM, and Get-Bulk requests. Get-Bulk request is available in version 2c and 3 of the SNMP. Two special options can be set for these requests, NonRepeaters and MaxRepetitions. NonRepeaters is a value telling the agent how many OIDs in the VbList are to be treated as a single GetNext request. MaxRepeaters tells the agent how many variable bindings to return in a single Pdu for each requested Oid.

Inheritance Hierarchy

See Also