SNMP Protocol Data Unit

Namespace:  SnmpSharpNet
Assembly:  SnmpSharpNet (in SnmpSharpNet.dll) Version: 0.5.0.0 (0.5.0.0)

Syntax

         
 C#  Visual Basic  Visual C++ 
public class Pdu : AsnType, ICloneable
Public Class Pdu _
	Inherits AsnType _
	Implements ICloneable
public ref class Pdu : public AsnType, 
	ICloneable

Members

            
 All Members  Constructors   Properties   Methods  
 Public

 Protected
 Instance

 Static 
 Declared

 Inherited
 XNA Framework Only 

 .NET Compact Framework Only 

 MemberDescription
Pdu()()()
Constructor.
Pdu(Pdu)
Constructor
Pdu(VbCollection)
Constructor.
Pdu(Byte)
Constructor.
Pdu(VbCollection, Byte, Int32)
Constructor.
Clone()()()
Clone this object
(Overrides AsnType..::.Clone()()().)
decode(array<Byte>[]()[], Int32)
Decode BER encoded Pdu
(Overrides AsnType..::.decode(array<Byte>[]()[], Int32).)
DeleteVb(Int32)
Delete VB from the specified location in the VarBind list
encode(MutableByte)
Encode Pdu class to BER byte buffer
(Overrides AsnType..::.encode(MutableByte).)
Equals(Object)
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
ErrorIndex
ErrorIndex Pdu value
ErrorStatus
ErrorStatus Pdu value
GetBulkPdu(VbCollection)
Create SNMP-GetBulk Pdu
GetHashCode()()()
Serves as a hash function for a particular type.
(Inherited from Object.)
GetNextPdu(VbCollection)
Create SNMP-GetNext Pdu
GetPdu(VbCollection)
Create SNMP-GET Pdu from VbList
GetType()()()
Gets the Type of the current instance.
(Inherited from Object.)
GetVb(Int32)
Get VB from VarBind list at the specified index
MaxRepetitions
Tells SNMP Agent how many VBs to include in a single request. Only valid on GETBULK requests.
NonRepeaters
Get/Set GET-BULK NonRepeaters value
RequestId
SNMP packet request id that is sent to the SNMP agent. SET this value before making SNMP requests.
Reset()()()
Reset VbList.
Set(AsnType)
Copy values from another Pdu class.
SetPdu(VbCollection)
Create SNMP-SET Pdu
SetVbList(VbCollection)
Set VbList
ToString()()()
Returns a String that represents the current Object.
(Inherited from Object.)
TrapObjectID
Get TRAP ObjectID class from SNMPv2 TRAP and INFORM PDUs
TrapSysUpTime
Get TRAP TimeStamp class from SNMPv2 TRAP and INFORM PDUs
Type
Get or SET the PDU type. Available types are GET, GETNEXT, SET, GETBULK. PDU types are defined in Pdu class.
VbCount
Return the number of VB entries in the VarBind list
VbList
VarBind list

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 = SnmpConstants.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 0 and during the encoding process, selects a random value for the RequestId. If you wish to set a specific RequestId, you can do it this way:
CopyC#
Pdu pdu = new Pdu();
pdu.Type = SnmpConstants.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 direct value OIDs and shouldn't be treated as GetNext-like retrieval. What this means is that if, for example, you wish to retrieve utilization values for all interfaces on an agent and you also wish to retrieve sysUpTime with the request, you would create a GetBulk request with 2 OIDs in VbList, first would be sysObjectId and second the interface utilization parent OID. Then you would set the NonRepeaters value to 1 which will tell the agent to return only the since value associated with sysUpTime.0 and then to proceed to fill the rest of the RESPONSE Pdu with the OID tree entries undef the interface utilization OID. MaxRepeaters tells the agent the maximum number of OIDs to return in a single Pdu. This is handy because you could set this value to 255 or some other high value and end up retrieving a lot of information you don't need that is past the end of the data you want to, or need to retrieve.

Inheritance Hierarchy

See Also