title: Decode packet fields using dpkt package in python
body: <p>I am trying to print the NTP fields using dpkt. It works well except that I couldn't get the output like the one I get from tcpdump. For instance, in the attached code, I couldn't print originate_time in human readable format. I tried functions in binascii but couldn't get it right. </p>
  
  <p>I am a newbie to dpkt and any pointers would be great.</p>
  
  <pre><code>import dpkt
  import socket
  
  def processPcap(iFile):
      f = open(iFile)
      pcap = dpkt.pcap.Reader(f)
  
      for ts, buf in pcap:
          eth = dpkt.ethernet.Ethernet(buf)
          ip = eth.data
          source = socket.inet_ntoa(ip.src)
          destination = socket.inet_ntoa(ip.dst)
          udp = ip.data
          if ip.p==dpkt.ip.IP_PROTO_UDP:
              if udp.dport == 123:
                  ntp = dpkt.ntp.NTP(udp.data)
                  print (("Timestamp:%s, Source:%s, Destination:%s, SPort:%s, DPort:%s") % (ts, source, destination, udp.sport, udp.dport))
                  print ntp.flags
                  print ntp.delay
                  print ntp.id
                  print ntp.dispersion
                  print ntp.update_time
                  print ntp.originate_time
  
      f.close()
  
  if __name__ == "__main__":
      INPUT = "&lt;inputFile&gt;"
      processPcap(INPUT)
  </code></pre>