<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _packet_listener(self):
 """ Packet listener. """


        while True:
            datastream, source = self._sock.recvfrom(BUFFERSIZE)
            ipaddr, port = source

            # mitigate against invalid packets
            try:
                sio = io.BytesIO(datastream)

                dummy1, sec_part = struct.unpack("<HH",
                                                 sio.read(4))

                protocol = sec_part % 4096

                if protocol == 1024:
                    source, dummy1, dummy2, dummy3, sequence, dummy4, \
                        payloadtype, dummy5 = struct.unpack("<IQ6sBBQHH",
                                                            sio.read(32))

                    if ipaddr == self._server_addr:
                        # ignore any broadcast packets
                        pass

                    elif payloadtype == PayloadType.ACKNOWLEDGEMENT:
                        self._process_packet(sequence)

                    #elif payloadtype == PayloadType.STATESERVICE:
                    #    serv, port = struct.unpack("<BI",
                    #                               sio.read(5))

                    #elif payloadtype == PayloadType.STATEHOSTINFO:
                    #    sig, _tx, _rx, res = struct.unpack("<fIIh",
                    #                                       sio.read(14))

                    #elif payloadtype == PayloadType.STATEHOSTFIRMWARE:
                    #    build, res, ver = struct.unpack("<QQI",
                    #                                    sio.read(20))

                    #elif payloadtype == PayloadType.STATEWIFIINFO:
                    #    sig, _tx, _rx, res = struct.unpack("<fIIh",
                    #                                       sio.read(14))

                    #elif payloadtype == PayloadType.STATEWIFIFIRMWARE:
                    #    build, _reserved, ver = struct.unpack("<QQI",
                    #                                          sio.read(20))

                    #elif payloadtype == PayloadType.STATEPOWER1:
                    #    level, = struct.unpack("<H",
                    #                           sio.read(2))

                    #elif payloadtype == PayloadType.STATELABEL:
                    #    label, = struct.unpack("<32s",
                    #                           sio.read(32))

                    #elif payloadtype == PayloadType.STATEVERSION:
                    #    ven, prod, ver = struct.unpack("<HHH",
                    #                                   sio.read(6))

                    #elif payloadtype == PayloadType.STATEINFO:
                    #    _tm, uptm, dwntm = struct.unpack("<QQQ",
                    #                                     sio.read(24))

                    #elif payloadtype == PayloadType.STATELOCATION:
                    #    loc, label, upd = struct.unpack("<10s32sQ",
                    #                                    sio.read(50))

                    #elif payloadtype == PayloadType.STATEGROUP:
                    #    grp, label, upd = struct.unpack("<16s32sQ",
                    #                                    sio.read(56))

                    #elif payloadtype == PayloadType.ECHORESPONSE:
                    #    dummy1, = struct.unpack("<64s",
                    #                            sio.read(64))

                    elif payloadtype == PayloadType.STATE:
                        hue, sat, bri, kel, dummy1, power, label, dummy2 = \
                            struct.unpack("<HHHHhH32sQ",
                                          sio.read(52))

                        name = label.decode('ascii')
                        name = name.replace('\x00', '')

                        # notify about device
                        self._device_callback(ipaddr, name, power, hue,
                                              sat, bri, kel)

                    #elif payloadtype == PayloadType.STATEPOWER2:
                    #    level, = struct.unpack("<H",
                    #                           sio.read(2))

            # pylint: disable=broad-except
            except Exception:
                pass