Suppose I'm writing an SNMP v1/2 agent.
Is it mandatory to append the instance number to the variable OIDs in a trap PDU?
In SNMP V1 for instance a trap is defined in RFC 1157, with these fields:
The "variable bindings" section consist of a list of variable names and values. According to RFC 1157 :
In general, the name of an SNMP variable is an OBJECT IDENTIFIER of the form x.y, where x is the name of a non-aggregate object type defined in the MIB and y is an OBJECT IDENTIFIER fragment that, in a way specific to the named object type, identifies the desired instance.
What's bothering me is the "In general", is the .y mandatory?
Yes, it's mandatory to include instance subidentifiers for any variable OIDs in the variable bindings. The paragraph is describing the general (i.e., generic) form for a variable OID, not using "in general" to mean a non-committal "well, it's usually like this, but not always". Later RFCs use more concrete wording:
A variable-binding list is a simple list of variable bindings.
The name of a variable is an OBJECT IDENTIFIER which is the concatenation of the OBJECT IDENTIFIER of the corresponding object- type together with an OBJECT IDENTIFIER fragment identifying the instance. The OBJECT IDENTIFIER of the corresponding object-type is called the OBJECT IDENTIFIER prefix of the variable.
[RFC 3416, section 2.1]