title: How to differentiate TCP and UDP packets in machine with java code?
body: <p>How to differentiate the TCP and UDP packets before sending it to the internet using java? I need to listen to those packets and differentiate whether it is TCP or UDP. How to achieve this using Java code?</p>
  
  <p>UPDATE:
  I need to redirect all the TCP/IP and UDP packects to a server (Ip) and need to track the traffic of the TCP/IP and UDP Packets and make a log.</p>