title: How to identify whether a received packet is using TCP or UDP, in java using jpcap?
body: <p>I want to parse my received packet in TCPPacket or UDPPacket, but if I write "TCPPacket pac3 = (TCPPacket) packet;"   for a packet  that is using UDP as transport layer protocol then I get an exception 
  "Exception in thread "main" java.lang.ClassCastException: jpcap.packet.UDPPacket cannot be cast to jpcap.packet.TCPPacket"</p>
  
  <p>How can I identify whether my received packet is using TCP or UDP? 
  Actually I want to get port numbers from a received packet.</p>