@conf.commands.register
def pkt2uptime(pkt, HZ=100):
 if (not isinstance(pkt, Packet)):
  raise TypeError('Not a TCP packet')
 if isinstance(pkt, NoPayload):
  raise TypeError('Not a TCP packet')
 if (not isinstance(pkt, TCP)):
  return pkt2uptime(pkt.payload)
 for opt in pkt.options:
  if (opt[0] == 'Timestamp'):
   t = (opt[1][0] / HZ)
   return t
 raise TypeError('No timestamp option')

@ conf . commands . register def pkt2uptime ( pkt , HZ = 100 ) : if ( not isinstance ( pkt , Packet ) ) : raise TypeError ( 'Not a TCP packet' ) if isinstance ( pkt , NoPayload ) : raise TypeError ( 'Not a TCP packet' ) if ( not isinstance ( pkt , TCP ) ) : return pkt2uptime ( pkt . payload ) for opt in pkt . options : if ( opt [ 0 ] == 'Timestamp' ) : t = ( opt [ 1 ] [ 0 ] / HZ ) return t raise TypeError ( 'No timestamp option' )
calculate the date the machine which emitted the packet booted using tcp timestamp pkt2uptime .