SNMP version 1 TRAP packet class.
Available packet classes are:
  • SnmpV1Packet
  • SnmpV1TrapPacket
  • SnmpV2Packet
  • SnmpV3Packet
This class is provided to simplify encoding and decoding of packets and to provide consistent interface for users who wish to handle transport part of protocol on their own without using the UdpTarget class. SnmpPacket and derived classes have been developed to implement SNMP packet support. For SNMP version 1 and 2 packet, SnmpV1Packet and SnmpV2Packet classes provides sufficient support for encoding and decoding data to/from BER buffers to satisfy requirements of most applications. SNMP version 3 on the other hand requires a lot more information to be passed to the encoder method and returned by the decode method. Attempt of implementing SNMP version 3 as part of SnmpV3Packet class was operational but required too many function arguments to operate so a different interface was developed using dedicated SnmpV3Packet class.
Inheritance: SnmpPacket
        ///<summary>
        ///Actual work in backgroundworker thread
        ///</summary>
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            // Construct a socket and bind it to the trap manager port 10162
            Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 162);
            EndPoint ep = (EndPoint)ipep;
            socket.Bind(ep);
            // Disable timeout processing. Just block until packet is received
            socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 0);
            bool run = true;
            int inlen;
            int ver;
            while (run)
            {
                byte[] indata = new byte[16 * 1024];
                // 16KB receive buffer int inlen = 0;
                IPEndPoint peer = new IPEndPoint(IPAddress.Any, 0);
                EndPoint inep = (EndPoint)peer;
                try
                {
                    inlen = socket.ReceiveFrom(indata, ref inep);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Exception {0}", ex.Message);
                    inlen = -1;
                }
                if (inlen > 0)
                {
                    // Check protocol version int
                    ver = SnmpPacket.GetProtocolVersion(indata, inlen);
                    if (ver == (int)SnmpVersion.Ver1)
                    {
                        // Parse SNMP Version 1 TRAP packet
                        SnmpV1TrapPacket pkt = new SnmpV1TrapPacket();
                        pkt.decode(indata, inlen);
                        Console.WriteLine("** SNMP Version 1 TRAP received from {0}:", inep.ToString());
                        Console.WriteLine("*** Trap generic: {0}", pkt.Pdu.Generic);
                        Console.WriteLine("*** Trap specific: {0}", pkt.Pdu.Specific);
                        Console.WriteLine("*** Agent address: {0}", pkt.Pdu.AgentAddress.ToString());
                        Console.WriteLine("*** Timestamp: {0}", pkt.Pdu.TimeStamp.ToString());
                        Console.WriteLine("*** VarBind count: {0}", pkt.Pdu.VbList.Count);
                        Console.WriteLine("*** VarBind content:");

                        //Looking for 1.3.6.1.3.5.0 and refreshing Plot.
                        double voltage = Double.Parse(pkt.Pdu.VbList[4].Value.ToString());
                        voltageLine.Points.Add(new DataPoint(double.Parse(pkt.Pdu.TimeStamp.ToString()), voltage));
                        model.RefreshPlot(true);
                        Console.WriteLine("** End of SNMP Version 1 TRAP data.");
                    }
                }
                else
                {
                    if (inlen == 0)
                        Console.WriteLine("Zero length packet received.");
                }
            }
            Yield(1000000);
        }
        /// <summary>
        /// Construct and send SNMP v1 Trap
        /// </summary>
        /// <param name="receiver">Receiver IP address</param>
        /// <param name="receiverPort">Receiver UDP port number</param>
        /// <param name="community">SNMP community name</param>
        /// <param name="senderSysObjectID">Senders sysObjectID</param>
        /// <param name="senderIpAdress">Sender IP address</param>
        /// <param name="genericTrap">Generic trap code</param>
        /// <param name="specificTrap">Specific trap code</param>
        /// <param name="senderUpTime">Senders sysUpTime</param>
        /// <param name="varList">Variable binding list</param>
        public void SendV1Trap(IpAddress receiver, int receiverPort, string community, Oid senderSysObjectID,
                               IpAddress senderIpAdress, Int32 genericTrap, Int32 specificTrap, UInt32 senderUpTime,
                               VbCollection varList)
        {
            SnmpV1TrapPacket packet = new SnmpV1TrapPacket(community);

            packet.Pdu.Generic  = genericTrap;
            packet.Pdu.Specific = specificTrap;
            packet.Pdu.AgentAddress.Set(senderIpAdress);
            packet.Pdu.TimeStamp = senderUpTime;
            packet.Pdu.VbList.Add(varList);
            packet.Pdu.Enterprise.Set(senderSysObjectID);
            SendV1Trap(packet, receiver, receiverPort);
        }
 /// <summary>
 /// Send SNMP version 1 Trap notification
 /// </summary>
 /// <param name="packet">SNMP v1 Trap packet class</param>
 /// <param name="peer">Manager (receiver) IP address</param>
 /// <param name="port">Manager (receiver) UDP port number</param>
 public void SendV1Trap(SnmpV1TrapPacket packet, IpAddress peer, int port)
 {
     byte[] outBuffer = packet.encode();
     _sock.SendTo(outBuffer, new IPEndPoint((IPAddress)peer, port));
 }
示例#4
0
        public void zlapPulapke()
        {
            /*! 
		     *Kod pochodzi ze strony http://www.snmpsharpnet.com/?page_id=117
             */
            Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 162);
            EndPoint ep = (EndPoint)ipep;
            socket.Bind(ep);
            // Disable timeout processing. Just block until packet is received 
            socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 0);
            bool run = true;
            int inlen = -1;
            while (run)
            {
                byte[] indata = new byte[16 * 1024];
                // 16KB receive buffer int inlen = 0;
                IPEndPoint peer = new IPEndPoint(IPAddress.Any, 0);
                EndPoint inep = (EndPoint)peer;
                try
                {
                    inlen = socket.ReceiveFrom(indata, ref inep);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Exception {0}", ex.Message);
                    inlen = -1;
                }
                if (inlen > 0)
                {
                    Console.WriteLine("TAK");

                    listaWierszyZeZlapanejPualpki.Clear();
                    // Check protocol version int 
                    int ver = SnmpPacket.GetProtocolVersion(indata, inlen);
                    if (ver == (int)SnmpVersion.Ver1)
                    {
                        // Parse SNMP Version 1 TRAP packet 
                        SnmpV1TrapPacket pkt = new SnmpV1TrapPacket();
                        pkt.decode(indata, inlen);
                        listaWierszyZeZlapanejPualpki.Add("** SNMP Version 1 TRAP otrzymane od " + inep.ToString());
                        listaWierszyZeZlapanejPualpki.Add("*** Trap generic: " + pkt.Pdu.Generic);
                        listaWierszyZeZlapanejPualpki.Add("*** Trap specific: " + pkt.Pdu.Specific);
                        listaWierszyZeZlapanejPualpki.Add("*** Agent address: " + pkt.Pdu.AgentAddress.ToString());
                        listaWierszyZeZlapanejPualpki.Add("*** Timestamp: " + pkt.Pdu.TimeStamp.ToString());
                        listaWierszyZeZlapanejPualpki.Add("*** VarBind count: " + pkt.Pdu.VbList.Count);
                        listaWierszyZeZlapanejPualpki.Add("*** VarBind content:");
                        foreach (Vb v in pkt.Pdu.VbList)
                        {
                            StringBuilder budowaStringa = new StringBuilder();
                            budowaStringa.Append("**** ");
                            budowaStringa.Append(v.Oid.ToString());
                            budowaStringa.Append(" " + SnmpConstants.GetTypeName(v.Value.Type));
                            budowaStringa.Append(": " + v.Value.ToString());
                            listaWierszyZeZlapanejPualpki.Add(budowaStringa.ToString());
                        }
                        listaWierszyZeZlapanejPualpki.Add("** Koniec SNMP Version 1 TRAP data.");
                        flagaWierszyZeZlapanejPulapki = true;
                        //return true;
                    }
                    else {
                        // Parse SNMP Version 2 TRAP packet 
                        SnmpV2Packet pkt = new SnmpV2Packet();
                        pkt.decode(indata, inlen);
                        listaWierszyZeZlapanejPualpki.Clear();
                        listaWierszyZeZlapanejPualpki.Add("** SNMP Version 2 TRAP otrzymane od " + inep.ToString());
                        if ((SnmpSharpNet.PduType)pkt.Pdu.Type != PduType.V2Trap)
                        {
                            listaWierszyZeZlapanejPualpki.Add("*** NOT an SNMPv2 trap ****");
                        }
                        else {
                            listaWierszyZeZlapanejPualpki.Add("*** Community: " + pkt.Community.ToString());
                            listaWierszyZeZlapanejPualpki.Add("*** VarBind count: " + pkt.Pdu.VbList.Count);
                            listaWierszyZeZlapanejPualpki.Add("*** VarBind content:");
                            foreach (Vb v in pkt.Pdu.VbList)
                            {
                                StringBuilder budowaStringa = new StringBuilder();
                                budowaStringa.Append("**** ");
                                budowaStringa.Append(v.Oid.ToString());
                                budowaStringa.Append(" " + SnmpConstants.GetTypeName(v.Value.Type));
                                budowaStringa.Append(": " + v.Value.ToString());
                                listaWierszyZeZlapanejPualpki.Add(budowaStringa.ToString());
                            }
                            listaWierszyZeZlapanejPualpki.Add("** Koniec SNMP Version 2 TRAP data.");
                        }
                        flagaWierszyZeZlapanejPulapki = true;
                        //return true;
                    }
                }
                else {
                    if (inlen == 0)
                    {
                        listaWierszyZeZlapanejPualpki.Clear();
                        listaWierszyZeZlapanejPualpki.Add("Przechwycono pusty pakiet");
                        flagaWierszyZeZlapanejPulapki = true;
                        //return true;
                    }
                }
            }
            //return false;
        }
    /// <summary>
    /// Thread that will keep listening for traps
    /// </summary>
    public void TrapThread()
    {
		// Construct a socket and bind it to the trap manager port 162 

		Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
		IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 16009);
		EndPoint ep = (EndPoint)ipep;
		socket.Bind(ep);
		// Disable timeout processing. Just block until packet is received 
		socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 0);
		run_trap_thread = true;
		int inlen = -1;

        while (run_trap_thread)
        {
			byte[] indata = new byte[16 * 1024];
			// 16KB receive buffer int inlen = 0;
			IPEndPoint peer = new IPEndPoint(IPAddress.Any, 0);
			EndPoint inep = (EndPoint)peer;
			
		    inlen = socket.ReceiveFrom(indata, ref inep);

			if (inlen > 0) {

				// Check protocol version int 
				int ver = SnmpPacket.GetProtocolVersion(indata, inlen);
					// Parse SNMP Version 1 TRAP packet 
					SnmpV1TrapPacket pkt = new SnmpV1TrapPacket();
					pkt.decode(indata, inlen);

                    string underAttackOid = "1";
                    string foundEnemyOid = "2";
                    string headOid = "5.1";
                    string legsOid = "5.2";
                    string armsOid = "5.3";


					foreach (Vb v in pkt.Pdu.VbList) {
                        Debug.Log("for each vb");

                        switch (v.Oid.ToString())
                        {
                            case "1.3.2.5." + "1":
                                underAttack = int.Parse(v.Value.ToString());
                                break;


                            // found enemy
                            case "1.3.2.5." + "2":
                                foundEnemy = int.Parse(v.Value.ToString());
                                break;
                            // head bellow 50
                            case "1.3.2.5." + "5.1":
                                healthWarning = 1;
                                HeadHealth = int.Parse(v.Value.ToString());
                                break;
                            // head bellow 25
                            case "1.3.2.5." + "5.2":
                                healthWarning = 1;
                                LegsHealth = int.Parse(v.Value.ToString());
                                break;
                            // head destroyed
                            case "1.3.2.5." + "5.3":
                                healthWarning = 1;
                                ArmHealth = int.Parse(v.Value.ToString());
                                break;

                            
                        }
                          

					}
				
			} else {
				if (inlen == 0)
					Console.WriteLine("Zero length packet received.");
			}
		}
        Debug.Log(" trap thread EXITT");

		
    }
示例#6
0
        /// <summary>
        /// Construct and send SNMP v1 Trap
        /// </summary>
        /// <param name="receiver">Receiver IP address</param>
        /// <param name="receiverPort">Receiver UDP port number</param>
        /// <param name="community">SNMP community name</param>
        /// <param name="senderSysObjectID">Senders sysObjectID</param>
        /// <param name="senderIpAdress">Sender IP address</param>
        /// <param name="genericTrap">Generic trap code</param>
        /// <param name="specificTrap">Specific trap code</param>
        /// <param name="senderUpTime">Senders sysUpTime</param>
        /// <param name="varList">Variable binding list</param>
        public void SendV1Trap(IpAddress receiver, int receiverPort, string community, Oid senderSysObjectID, 
			IpAddress senderIpAdress, Int32 genericTrap, Int32 specificTrap, UInt32 senderUpTime, 
			VbCollection varList)
        {
            SnmpV1TrapPacket packet = new SnmpV1TrapPacket(community);
            packet.Pdu.Generic = genericTrap;
            packet.Pdu.Specific = specificTrap;
            packet.Pdu.AgentAddress.Set(senderIpAdress);
            packet.Pdu.TimeStamp = senderUpTime;
            packet.Pdu.VbList.Add(varList);
            packet.Pdu.Enterprise.Set(senderSysObjectID);
            SendV1Trap(packet, receiver, receiverPort);
        }
示例#7
0
 /// <summary>
 /// Send SNMP version 1 Trap notification
 /// </summary>
 /// <param name="packet">SNMP v1 Trap packet class</param>
 /// <param name="peer">Manager (receiver) IP address</param>
 /// <param name="port">Manager (receiver) UDP port number</param>
 public void SendV1Trap(SnmpV1TrapPacket packet, IpAddress peer, int port)
 {
     byte[] outBuffer = packet.encode();
     _sock.SendTo(outBuffer, new IPEndPoint((IPAddress)peer, port));
 }
示例#8
0
        private void button1_Click(object sender, EventArgs e)
        {
            // Construct a socket and bind it to the trap manager port 162
            Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 162);
            EndPoint ep = (EndPoint)ipep;
            socket.Bind(ep);
            // Disable timeout processing. Just block until packet is received
            socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 0);
            bool run = true;
            int inlen = -1;
            while (run)
            {
                Application.DoEvents();
                Thread.Sleep(100);
                byte[] indata = new byte[16 * 1024];
                // 16KB receive buffer int inlen = 0;
                IPEndPoint peer = new IPEndPoint(IPAddress.Any, 0);
                EndPoint inep = (EndPoint)peer;
                try
                {

                    inlen = socket.ReceiveFrom(indata, ref inep);

                }
                catch (Exception ex)
                {
                    Console.WriteLine("Exception {0}", ex.Message);
                    inlen = -1;
                }
                if (inlen > 0)
                {
                    // Check protocol version int
                    int ver = SnmpPacket.GetProtocolVersion(indata, inlen);
                    if (ver == (int)SnmpVersion.Ver1)
                    {
                        // Parse SNMP Version 1 TRAP packet
                        SnmpV1TrapPacket pkt = new SnmpV1TrapPacket();
                        pkt.decode(indata, inlen);
                        Console.WriteLine("** SNMP Version 1 TRAP received from {0}:", inep.ToString());
                        Console.WriteLine("*** Trap generic: {0}", pkt.Pdu.Generic);
                        Console.WriteLine("*** Trap specific: {0}", pkt.Pdu.Specific);
                        Console.WriteLine("*** Agent address: {0}", pkt.Pdu.AgentAddress.ToString());
                        Console.WriteLine("*** Timestamp: {0}", pkt.Pdu.TimeStamp.ToString());
                        Console.WriteLine("*** VarBind count: {0}", pkt.Pdu.VbList.Count);
                        Console.WriteLine("*** VarBind content:");
                        foreach (Vb v in pkt.Pdu.VbList)
                        {
                            Console.WriteLine("**** {0} {1}: {2}", v.Oid.ToString(), SnmpConstants.GetTypeName(v.Value.Type), v.Value.ToString());
                            textBox1.Text += "\n" + v.Oid.ToString() + "|" + SnmpConstants.GetTypeName(v.Value.Type) + "|" + v.Value.ToString();
                        }
                        Console.WriteLine("** End of SNMP Version 1 TRAP data.");
                    }
                    else
                    {
                        // Parse SNMP Version 2 TRAP packet
                        SnmpV2Packet pkt = new SnmpV2Packet();
                        pkt.decode(indata, inlen);
                        Console.WriteLine("** SNMP Version 2 TRAP received from {0}:", inep.ToString());
                        if ((SnmpSharpNet.PduType)pkt.Pdu.Type != PduType.V2Trap)
                        {
                            Console.WriteLine("*** NOT an SNMPv2 trap ****");
                        }
                        else
                        {
                            Console.WriteLine("*** Community: {0}", pkt.Community.ToString());
                            Console.WriteLine("*** VarBind count: {0}", pkt.Pdu.VbList.Count);
                            Console.WriteLine("*** VarBind content:");
                            foreach (Vb v in pkt.Pdu.VbList)
                            {
                                Console.WriteLine("**** {0} {1}: {2}",
                                   v.Oid.ToString(), SnmpConstants.GetTypeName(v.Value.Type), v.Value.ToString());
                            }
                            Console.WriteLine("** End of SNMP Version 2 TRAP data.");
                        }
                    }
                }
                else
                {
                    if (inlen == 0)
                        Console.WriteLine("Zero length packet received.");
                }
            }
        }
        ///<summary>
        ///Actual work in backgroundworker thread
        ///</summary>
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            // Construct a socket and bind it to the trap manager port 10162
            Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 10162);
            EndPoint ep = (EndPoint)ipep;
            socket.Bind(ep);
            // Disable timeout processing. Just block until packet is received
            socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 0);
            bool run = true;
            int inlen;
            int ver;
            while (run)
            {
                byte[] indata = new byte[16 * 1024];
                // 16KB receive buffer int inlen = 0;
                IPEndPoint peer = new IPEndPoint(IPAddress.Any, 0);
                EndPoint inep = (EndPoint)peer;
                try
                {
                    inlen = socket.ReceiveFrom(indata, ref inep);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Exception {0}", ex.Message);
                    inlen = -1;
                }
                if (inlen > 0)
                {
                    // Check protocol version int
                    ver = SnmpPacket.GetProtocolVersion(indata, inlen);
                    if (ver == (int)SnmpVersion.Ver1)
                    {
                        // Parse SNMP Version 1 TRAP packet
                        SnmpV1TrapPacket pkt = new SnmpV1TrapPacket();
                        pkt.decode(indata, inlen);
                        Console.WriteLine("** SNMP Version 1 TRAP received from {0}:", inep.ToString());
                        Console.WriteLine("*** Trap generic: {0}", pkt.Pdu.Generic);
                        Console.WriteLine("*** Trap specific: {0}", pkt.Pdu.Specific);
                        Console.WriteLine("*** Agent address: {0}", pkt.Pdu.AgentAddress.ToString());
                        Console.WriteLine("*** Timestamp: {0}", pkt.Pdu.TimeStamp.ToString());
                        Console.WriteLine("*** VarBind count: {0}", pkt.Pdu.VbList.Count);
                        Console.WriteLine("*** VarBind content:");
                        foreach (Vb v in pkt.Pdu.VbList)
                        {
                            Console.WriteLine("**** {0} {1}: {2}", v.Oid.ToString(), SnmpConstants.GetTypeName(v.Value.Type), v.Value.ToString());
                            string voltage = v.Value.ToString();
                            double max = 3.3;
                            string[] values = voltage.Split('V');
                            _worker.ReportProgress((int)Math.Floor((double)((double.Parse(values[0], CultureInfo.InvariantCulture) / max * 100))));
                            currentVoltage = voltage;
                            double test = double.Parse(values[0]);
                            voltageLine.Points.Add(new DataPoint(double.Parse(pkt.Pdu.TimeStamp.ToString()), double.Parse(values[0], CultureInfo.InvariantCulture)));
                            model.RefreshPlot(true);
                        }
                        Console.WriteLine("** End of SNMP Version 1 TRAP data.");
                    }
                }
                else
                {
                    if (inlen == 0)
                        Console.WriteLine("Zero length packet received.");
                }
            }
            Yield(1000000);
        }
示例#10
0
        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker parentWorker = sender as BackgroundWorker;
            bool running = true;

            // Construct a socket and bind it to the trap manager port 162
            Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            IPAddress ip = IPAddress.Parse(LISTEN_IP);
            IPEndPoint ipep = new IPEndPoint(ip, LISTEN_PORT);
            EndPoint ep = (EndPoint)ipep;
            socket.Bind(ep);
            // Disable timeout processing. Just block until packet is received
            socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 0);
            while (running) {
                byte[] indata = new byte[16 * 1024];
                // 16KB receive buffer int inlen = 0;
                IPEndPoint peer = new IPEndPoint(IPAddress.Any, 0);
                EndPoint inep = (EndPoint)peer;
                int inlen = 0;
                int ver;
                try {
                    inlen = socket.ReceiveFrom(indata, ref inep);
                } catch (Exception ex) {
                    Console.WriteLine("Exception {0}", ex.Message);
                    inlen = -1;
                }
                if (inlen > 0) {
                    Console.WriteLine("inlen > 0");
                    // Check protocol version int
                    ver = SnmpPacket.GetProtocolVersion(indata, inlen);
                    if (ver == (int)SnmpVersion.Ver1) {
                        // Parse SNMP Version 1 TRAP packet
                        SnmpV1TrapPacket pkt = new SnmpV1TrapPacket();
                        pkt.decode(indata, inlen);
                        Console.WriteLine("** SNMP Version 1 TRAP received from {0}:", inep.ToString());
                        Console.WriteLine("*** Trap generic: {0}", pkt.Pdu.Generic);
                        Console.WriteLine("*** Trap specific: {0}", pkt.Pdu.Specific);
                        Console.WriteLine("*** Agent address: {0}", pkt.Pdu.AgentAddress.ToString());
                        Console.WriteLine("*** Timestamp: {0}", pkt.Pdu.TimeStamp.ToString());
                        Console.WriteLine("*** VarBind count: {0}", pkt.Pdu.VbList.Count);
                        Console.WriteLine("*** VarBind content:");
                        foreach (Vb v in pkt.Pdu.VbList) {
                            Console.WriteLine("**** {0} {1}: {2}", v.Oid.ToString(), SnmpConstants.GetTypeName(v.Value.Type), v.Value.ToString());
                            if (v.Oid.ToString().Equals(SNMP_OID_VOLTAGE)) {
                                this.currentVoltage = double.Parse(v.Value.ToString(), CultureInfo.InvariantCulture);
                                this.lsVoltage.Points.Add(new DataPoint(pkt.Pdu.TimeStamp, this.currentVoltage));

                                dataPoints++;
                                if (dataPoints >= 50) {
                                    for (int i = 0; i < dataPoints - 50; i++) {
                                        this.lsVoltage.Points.RemoveAt(i);
                                        dataPoints--;
                                    }
                                }
                                this.pModel.RefreshPlot(true);
                                parentWorker.ReportProgress((int)Math.Floor((this.currentVoltage / MAX_VOLTAGE) * 100));
                            }
                        }
                        Console.WriteLine("** End of SNMP Version 1 TRAP data.");

                    }
                } else {
                    if (inlen == 0)
                        Console.WriteLine("Zero length packet received.");
                }
            }
        }