while header:
    eth = dpkt.ethernet.Ethernet(str(payload))
if eth.type != dpkt.ethernet.ETH_TYPE_IP:
    continue
ip = eth.data
if ip.p == dpkt.ip.IP_PROTO_TCP:
    TCP = ip.data
elif ip.p == dpkt.ip.IP_PROTO_UDP:
    UDP = ip.data
header, payload = next(cap)
python / dpkt: Find out if packet is a tcp packet or a udp packet ,