'Build discovery packet'

def create_discovery_packet(self, dpid, port_num, port_addr):

    chassis_id = pkt.chassis_id(subtype=pkt.chassis_id.SUB_LOCAL)
    chassis_id.id = bytes(('dpid:' + hex(long(dpid))[2:(-1)]))
    port_id = pkt.port_id(subtype=pkt.port_id.SUB_PORT, id=str(port_num))
    ttl = pkt.ttl(ttl=self._ttl)
    sysdesc = pkt.system_description()
    sysdesc.payload = bytes(('dpid:' + hex(long(dpid))[2:(-1)]))
    discovery_packet = pkt.lldp()
    discovery_packet.tlvs.append(chassis_id)
    discovery_packet.tlvs.append(port_id)
    discovery_packet.tlvs.append(ttl)
    discovery_packet.tlvs.append(sysdesc)
    discovery_packet.tlvs.append(pkt.end_tlv())
    eth = pkt.ethernet(type=pkt.ethernet.LLDP_TYPE)
    eth.src = port_addr
    eth.dst = pkt.ETHERNET.NDP_MULTICAST
    eth.payload = discovery_packet
    po = of.ofp_packet_out(action=of.ofp_action_output(port=port_num))
    po.data = eth.pack()
    return po.pack()
